Reland 8749: AudioEncoder: return EncodedInfo from Encode() and EncodeInternal()
Old review at: https://webrtc-codereview.appspot.com/43839004/ R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45769004 Cr-Commit-Position: refs/heads/master@{#8788} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8788 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -183,19 +183,18 @@ void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) {
|
||||
}
|
||||
}
|
||||
|
||||
void AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp,
|
||||
const int16_t* audio,
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
EncodedInfo* info) {
|
||||
AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
|
||||
uint32_t rtp_timestamp,
|
||||
const int16_t* audio,
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded) {
|
||||
if (input_buffer_.empty())
|
||||
first_timestamp_in_buffer_ = rtp_timestamp;
|
||||
input_buffer_.insert(input_buffer_.end(), audio,
|
||||
audio + samples_per_10ms_frame_);
|
||||
if (input_buffer_.size() < (static_cast<size_t>(num_10ms_frames_per_packet_) *
|
||||
samples_per_10ms_frame_)) {
|
||||
info->encoded_bytes = 0;
|
||||
return;
|
||||
return EncodedInfo();
|
||||
}
|
||||
CHECK_EQ(input_buffer_.size(),
|
||||
static_cast<size_t>(num_10ms_frames_per_packet_) *
|
||||
@ -207,12 +206,13 @@ void AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp,
|
||||
ClampInt16(max_encoded_bytes), encoded);
|
||||
CHECK_GE(r, 0); // Fails only if fed invalid data.
|
||||
input_buffer_.clear();
|
||||
info->encoded_bytes = r;
|
||||
info->encoded_timestamp = first_timestamp_in_buffer_;
|
||||
info->payload_type = payload_type_;
|
||||
// Allows Opus to send empty packets.
|
||||
info->send_even_if_empty = true;
|
||||
info->speech = r > 0;
|
||||
EncodedInfo info;
|
||||
info.encoded_bytes = r;
|
||||
info.encoded_timestamp = first_timestamp_in_buffer_;
|
||||
info.payload_type = payload_type_;
|
||||
info.send_even_if_empty = true; // Allows Opus to send empty packets.
|
||||
info.speech = r > 0;
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -58,11 +58,10 @@ class AudioEncoderOpus final : public AudioEncoder {
|
||||
bool dtx_enabled() const { return dtx_enabled_; }
|
||||
|
||||
protected:
|
||||
void EncodeInternal(uint32_t rtp_timestamp,
|
||||
const int16_t* audio,
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
EncodedInfo* info) override;
|
||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
||||
const int16_t* audio,
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded) override;
|
||||
|
||||
private:
|
||||
const int num_10ms_frames_per_packet_;
|
||||
|
||||
Reference in New Issue
Block a user