| Index: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| index 707d6c24884683ce00b5fb849ebd91f0406c1b51..bd3af22b461fe0e764fa15b543cfc5f7b7a62dc5 100644
|
| --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| +++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| @@ -133,11 +133,11 @@ int AudioEncoderOpus::GetTargetBitrate() const {
|
| AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
|
| uint32_t rtp_timestamp,
|
| rtc::ArrayView<const int16_t> audio,
|
| - size_t max_encoded_bytes,
|
| - uint8_t* encoded) {
|
| + rtc::Buffer* encoded) {
|
| +
|
| if (input_buffer_.empty())
|
| first_timestamp_in_buffer_ = rtp_timestamp;
|
| - RTC_DCHECK_EQ(SamplesPer10msFrame(), audio.size());
|
| +
|
| input_buffer_.insert(input_buffer_.end(), audio.cbegin(), audio.cend());
|
| if (input_buffer_.size() <
|
| (Num10msFramesPerPacket() * SamplesPer10msFrame())) {
|
| @@ -145,18 +145,29 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
|
| }
|
| RTC_CHECK_EQ(input_buffer_.size(),
|
| Num10msFramesPerPacket() * SamplesPer10msFrame());
|
| - int status = WebRtcOpus_Encode(
|
| - inst_, &input_buffer_[0],
|
| - rtc::CheckedDivExact(input_buffer_.size(), config_.num_channels),
|
| - rtc::saturated_cast<int16_t>(max_encoded_bytes), encoded);
|
| - RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
|
| - input_buffer_.clear();
|
| +
|
| + const size_t max_encoded_bytes = MaxEncodedBytes();
|
| EncodedInfo info;
|
| - info.encoded_bytes = static_cast<size_t>(status);
|
| + info.encoded_bytes =
|
| + encoded->AppendData(
|
| + max_encoded_bytes, [&] (rtc::ArrayView<uint8_t> encoded) {
|
| + int status = WebRtcOpus_Encode(
|
| + inst_, &input_buffer_[0],
|
| + rtc::CheckedDivExact(input_buffer_.size(),
|
| + config_.num_channels),
|
| + rtc::saturated_cast<int16_t>(max_encoded_bytes),
|
| + encoded.data());
|
| +
|
| + RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
|
| +
|
| + return static_cast<size_t>(status);
|
| + });
|
| + input_buffer_.clear();
|
| +
|
| info.encoded_timestamp = first_timestamp_in_buffer_;
|
| info.payload_type = config_.payload_type;
|
| info.send_even_if_empty = true; // Allows Opus to send empty packets.
|
| - info.speech = (status > 0);
|
| + info.speech = (info.encoded_bytes > 0);
|
| return info;
|
| }
|
|
|
|
|