We changed Encode() and EncodeInternal() return type from bool to void in this issue:

https://webrtc-codereview.appspot.com/38279004/
Now we don't have to pass EncodedInfo as output parameter, but can return it instead. This also adds the benefit of making clear that EncodeInternal() needs to fill in this info.

R=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/43839004

Cr-Commit-Position: refs/heads/master@{#8749}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8749 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
jmarusic@webrtc.org
2015-03-17 12:12:17 +00:00
parent 73d763e71f
commit 0cb612b43b
21 changed files with 222 additions and 237 deletions

View File

@ -63,11 +63,11 @@ int AudioEncoderIlbc::Max10MsFramesInAPacket() const {
return num_10ms_frames_per_packet_;
}
void AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp,
const int16_t* audio,
size_t max_encoded_bytes,
uint8_t* encoded,
EncodedInfo* info) {
AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal(
uint32_t rtp_timestamp,
const int16_t* audio,
size_t max_encoded_bytes,
uint8_t* encoded) {
DCHECK_GE(max_encoded_bytes, RequiredOutputSizeBytes());
// Save timestamp if starting a new packet.
@ -82,8 +82,7 @@ void AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp,
// If we don't yet have enough buffered input for a whole packet, we're done
// for now.
if (++num_10ms_frames_buffered_ < num_10ms_frames_per_packet_) {
info->encoded_bytes = 0;
return;
return kZeroEncodedBytes;
}
// Encode buffered input.
@ -95,10 +94,12 @@ void AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp,
kSampleRateHz / 100 * num_10ms_frames_per_packet_,
encoded);
CHECK_GE(output_len, 0);
info->encoded_bytes = output_len;
DCHECK_EQ(info->encoded_bytes, RequiredOutputSizeBytes());
info->encoded_timestamp = first_timestamp_in_buffer_;
info->payload_type = payload_type_;
EncodedInfo info;
info.encoded_bytes = output_len;
DCHECK_EQ(info.encoded_bytes, RequiredOutputSizeBytes());
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = payload_type_;
return info;
}
size_t AudioEncoderIlbc::RequiredOutputSizeBytes() const {

View File

@ -38,11 +38,10 @@ class AudioEncoderIlbc : public AudioEncoder {
int Max10MsFramesInAPacket() const override;
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:
size_t RequiredOutputSizeBytes() const;