From b1f0de30be3397eba3d423b71abc5c50db2a1665 Mon Sep 17 00:00:00 2001 From: "jmarusic@webrtc.org" Date: Thu, 26 Feb 2015 15:38:10 +0000 Subject: [PATCH] AudioEncoder: change Encode and EncodeInternal return type to void After code cleanup done on issues: https://webrtc-codereview.appspot.com/34259004/ https://webrtc-codereview.appspot.com/43409004/ https://webrtc-codereview.appspot.com/34309004/ https://webrtc-codereview.appspot.com/34309004/ https://webrtc-codereview.appspot.com/36209004/ https://webrtc-codereview.appspot.com/40899004/ https://webrtc-codereview.appspot.com/39279004/ https://webrtc-codereview.appspot.com/42099005/ and the similar work done for AudioEncoderDecoderIsacT, methods AudioEncoder::Encode and AudioEncoder::EncodeInternal will always succeed. Therefore, there is no need for them to return bool value that represents success or failure. R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/38279004 Cr-Commit-Position: refs/heads/master@{#8518} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8518 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_coding/codecs/audio_encoder.cc | 6 ++--- .../audio_coding/codecs/audio_encoder.h | 13 +++++------ .../codecs/cng/audio_encoder_cng.cc | 18 ++++++--------- .../codecs/cng/audio_encoder_cng_unittest.cc | 22 ++++++++----------- .../codecs/cng/include/audio_encoder_cng.h | 2 +- .../codecs/g711/audio_encoder_pcm.cc | 5 ++--- .../codecs/g711/include/audio_encoder_pcm.h | 2 +- .../codecs/g722/audio_encoder_g722.cc | 5 ++--- .../codecs/g722/include/audio_encoder_g722.h | 2 +- .../codecs/ilbc/audio_encoder_ilbc.cc | 5 ++--- .../ilbc/interface/audio_encoder_ilbc.h | 2 +- .../codecs/isac/audio_encoder_isac_t.h | 2 +- .../codecs/isac/audio_encoder_isac_t_impl.h | 13 ++++------- .../source/audio_encoder_isac_red_unittest.cc | 9 ++++---- .../codecs/mock/mock_audio_encoder.h | 2 +- .../codecs/opus/audio_encoder_opus.cc | 5 ++--- .../opus/interface/audio_encoder_opus.h | 2 +- .../codecs/red/audio_encoder_copy_red.cc | 9 ++++---- .../codecs/red/audio_encoder_copy_red.h | 2 +- .../red/audio_encoder_copy_red_unittest.cc | 18 +++++++-------- .../main/acm2/acm_generic_codec.cc | 6 ++--- .../neteq/audio_decoder_unittest.cc | 6 ++--- 22 files changed, 66 insertions(+), 90 deletions(-) diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.cc b/webrtc/modules/audio_coding/codecs/audio_encoder.cc index ae82509ef..1d83e54a0 100644 --- a/webrtc/modules/audio_coding/codecs/audio_encoder.cc +++ b/webrtc/modules/audio_coding/codecs/audio_encoder.cc @@ -19,7 +19,7 @@ AudioEncoder::EncodedInfo::EncodedInfo() : EncodedInfoLeaf() { AudioEncoder::EncodedInfo::~EncodedInfo() { } -bool AudioEncoder::Encode(uint32_t rtp_timestamp, +void AudioEncoder::Encode(uint32_t rtp_timestamp, const int16_t* audio, size_t num_samples_per_channel, size_t max_encoded_bytes, @@ -27,10 +27,8 @@ bool AudioEncoder::Encode(uint32_t rtp_timestamp, EncodedInfo* info) { CHECK_EQ(num_samples_per_channel, static_cast(SampleRateHz() / 100)); - bool ret = - EncodeInternal(rtp_timestamp, audio, max_encoded_bytes, encoded, info); + EncodeInternal(rtp_timestamp, audio, max_encoded_bytes, encoded, info); CHECK_LE(info->encoded_bytes, max_encoded_bytes); - return ret; } int AudioEncoder::RtpTimestampRateHz() const { diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.h b/webrtc/modules/audio_coding/codecs/audio_encoder.h index c02c3efd2..08cf66f75 100644 --- a/webrtc/modules/audio_coding/codecs/audio_encoder.h +++ b/webrtc/modules/audio_coding/codecs/audio_encoder.h @@ -56,12 +56,11 @@ class AudioEncoder { // Accepts one 10 ms block of input audio (i.e., sample_rate_hz() / 100 * // num_channels() samples). Multi-channel audio must be sample-interleaved. - // If successful, the encoder produces zero or more bytes of output in - // |encoded|, and provides the number of encoded bytes in |encoded_bytes|. - // In case of error, false is returned, otherwise true. It is an error for the - // encoder to attempt to produce more than |max_encoded_bytes| bytes of - // output. - bool Encode(uint32_t rtp_timestamp, + // The encoder produces zero or more bytes of output in |encoded|, + // and provides the number of encoded bytes in |encoded_bytes|. + // The caller is responsible for making sure that |max_encoded_bytes| is + // not smaller than the number of bytes actually produced by the encoder. + void Encode(uint32_t rtp_timestamp, const int16_t* audio, size_t num_samples_per_channel, size_t max_encoded_bytes, @@ -98,7 +97,7 @@ class AudioEncoder { virtual void SetProjectedPacketLossRate(double fraction) {} protected: - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc index ffab9ecf2..e14ac932d 100644 --- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc +++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc @@ -95,15 +95,12 @@ void AudioEncoderCng::SetProjectedPacketLossRate(double fraction) { speech_encoder_->SetProjectedPacketLossRate(fraction); } -bool AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, EncodedInfo* info) { - DCHECK_GE(max_encoded_bytes, static_cast(num_cng_coefficients_ + 1)); - if (max_encoded_bytes < static_cast(num_cng_coefficients_ + 1)) { - return false; - } + CHECK_GE(max_encoded_bytes, static_cast(num_cng_coefficients_ + 1)); info->encoded_bytes = 0; const int num_samples = SampleRateHz() / 100 * NumChannels(); if (speech_buffer_.empty()) { @@ -115,7 +112,7 @@ bool AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp, } ++frames_in_buffer_; if (frames_in_buffer_ < speech_encoder_->Num10MsFramesInNextPacket()) { - return true; + return; } CHECK_LE(frames_in_buffer_, 6) << "Frame size cannot be larger than 60 ms when using VAD/CNG."; @@ -169,7 +166,6 @@ bool AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp, speech_buffer_.clear(); frames_in_buffer_ = 0; - return true; } void AudioEncoderCng::EncodePassive(uint8_t* encoded, size_t* encoded_bytes) { @@ -196,10 +192,10 @@ void AudioEncoderCng::EncodeActive(size_t max_encoded_bytes, EncodedInfo* info) { const size_t samples_per_10ms_frame = 10 * SampleRateHz() / 1000; for (int i = 0; i < frames_in_buffer_; ++i) { - CHECK(speech_encoder_->Encode(first_timestamp_in_buffer_, - &speech_buffer_[i * samples_per_10ms_frame], - samples_per_10ms_frame, max_encoded_bytes, - encoded, info)); + speech_encoder_->Encode(first_timestamp_in_buffer_, + &speech_buffer_[i * samples_per_10ms_frame], + samples_per_10ms_frame, max_encoded_bytes, + encoded, info); if (i < frames_in_buffer_ - 1) { CHECK_EQ(info->encoded_bytes, 0u) << "Encoder delivered data too early."; } diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc index 8478839d5..c2a9ce3f1 100644 --- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc @@ -72,8 +72,8 @@ class AudioEncoderCngTest : public ::testing::Test { void Encode() { ASSERT_TRUE(cng_) << "Must call CreateCng() first."; encoded_info_ = AudioEncoder::EncodedInfo(); - ASSERT_TRUE(cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, - kMaxEncodedBytes, encoded_, &encoded_info_)); + cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, + kMaxEncodedBytes, encoded_, &encoded_info_); timestamp_ += num_audio_samples_10ms_; } @@ -101,11 +101,11 @@ class AudioEncoderCngTest : public ::testing::Test { InSequence s; for (int j = 0; j < blocks_per_frame - 1; ++j) { EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); } info.encoded_bytes = kMockReturnEncodedBytes; EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); } Encode(); if (active_speech) { @@ -280,20 +280,17 @@ TEST_F(AudioEncoderCngTest, MixedActivePassive) { // All of the frame is active speech. EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .Times(6) - .WillRepeatedly(Return(true)); + .Times(6); EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kActive)); // First half of the frame is active speech. EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .Times(6) - .WillRepeatedly(Return(true)); + .Times(6); EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kPassive)); // Second half of the frame is active speech. EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .Times(6) - .WillRepeatedly(Return(true)); + .Times(6); EXPECT_TRUE(CheckMixedActivePassive(Vad::kPassive, Vad::kActive)); // All of the frame is passive speech. Expect no calls to |mock_encoder_|. @@ -335,8 +332,7 @@ TEST_F(AudioEncoderCngTest, VadInputSize60Ms) { // speech encoder. TEST_F(AudioEncoderCngTest, VerifyEncoderInfoPropagation) { CreateCng(); - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, &encoded_info_)) - .WillOnce(Return(true)); + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, &encoded_info_)); EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1)); EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) .WillOnce(Return(Vad::kActive)); @@ -381,7 +377,7 @@ TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) { AudioEncoder::EncodedInfo info; info.encoded_bytes = kMockReturnEncodedBytes; EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); Encode(); EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes); diff --git a/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h b/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h index 46ad72762..2f5167622 100644 --- a/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h +++ b/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h @@ -55,7 +55,7 @@ class AudioEncoderCng final : public AudioEncoder { void SetProjectedPacketLossRate(double fraction) override; protected: - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc index 2b5b690cd..284a086db 100644 --- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc +++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc @@ -60,7 +60,7 @@ int AudioEncoderPcm::Max10MsFramesInAPacket() const { return num_10ms_frames_per_packet_; } -bool AudioEncoderPcm::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderPcm::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, @@ -74,7 +74,7 @@ bool AudioEncoderPcm::EncodeInternal(uint32_t rtp_timestamp, } if (speech_buffer_.size() < static_cast(full_frame_samples_)) { info->encoded_bytes = 0; - return true; + return; } CHECK_EQ(speech_buffer_.size(), static_cast(full_frame_samples_)); int16_t ret = EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded); @@ -83,7 +83,6 @@ bool AudioEncoderPcm::EncodeInternal(uint32_t rtp_timestamp, info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; info->encoded_bytes = static_cast(ret); - return true; } int16_t AudioEncoderPcmA::EncodeCall(const int16_t* audio, diff --git a/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h b/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h index 9365c43d0..903b22008 100644 --- a/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h +++ b/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h @@ -40,7 +40,7 @@ class AudioEncoderPcm : public AudioEncoder { protected: AudioEncoderPcm(const Config& config, int sample_rate_hz); - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc index 7a2ec6288..f02bda03a 100644 --- a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc +++ b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc @@ -69,7 +69,7 @@ int AudioEncoderG722::Max10MsFramesInAPacket() const { return num_10ms_frames_per_packet_; } -bool AudioEncoderG722::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderG722::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, @@ -91,7 +91,7 @@ bool AudioEncoderG722::EncodeInternal(uint32_t rtp_timestamp, // If we don't yet have enough samples for a packet, we're done for now. if (++num_10ms_frames_buffered_ < num_10ms_frames_per_packet_) { info->encoded_bytes = 0; - return true; + return; } // Encode each channel separately. @@ -121,7 +121,6 @@ bool AudioEncoderG722::EncodeInternal(uint32_t rtp_timestamp, info->encoded_bytes = samples_per_channel / 2 * num_channels_; info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; - return true; } } // namespace webrtc diff --git a/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h b/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h index 4439bc1e6..65a0d4ba7 100644 --- a/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h +++ b/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h @@ -37,7 +37,7 @@ class AudioEncoderG722 : public AudioEncoder { virtual int Max10MsFramesInAPacket() const OVERRIDE; protected: - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc index 79c01ddb7..b93934121 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc +++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc @@ -56,7 +56,7 @@ int AudioEncoderIlbc::Max10MsFramesInAPacket() const { return num_10ms_frames_per_packet_; } -bool AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, @@ -93,7 +93,7 @@ bool AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp, // for now. if (++num_10ms_frames_buffered_ < num_10ms_frames_per_packet_) { info->encoded_bytes = 0; - return true; + return; } // Encode buffered input. @@ -109,7 +109,6 @@ bool AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp, info->encoded_bytes = output_len; info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; - return true; } } // namespace webrtc diff --git a/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h b/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h index 15c0e000f..25c397a14 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h +++ b/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h @@ -37,7 +37,7 @@ class AudioEncoderIlbc : public AudioEncoder { virtual int Max10MsFramesInAPacket() const OVERRIDE; protected: - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h index 2279c3dda..4b56b91f0 100644 --- a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h +++ b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h @@ -95,7 +95,7 @@ class AudioEncoderDecoderIsacT : public AudioEncoder, public AudioDecoder { protected: // AudioEncoder protected method. - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h index d9cec82cf..7ac51b6e3 100644 --- a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h +++ b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h @@ -186,7 +186,7 @@ int AudioEncoderDecoderIsacT::Max10MsFramesInAPacket() const { } template -bool AudioEncoderDecoderIsacT::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderDecoderIsacT::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, @@ -202,11 +202,7 @@ bool AudioEncoderDecoderIsacT::EncodeInternal(uint32_t rtp_timestamp, CriticalSectionScoped cs(state_lock_.get()); r = T::Encode(isac_state_, audio, encoded); } - if (r < 0) { - // An error occurred; propagate it to the caller. - packet_in_progress_ = false; - return false; - } + CHECK_GE(r, 0); // T::Encode doesn't allow us to tell it the size of the output // buffer. All we can do is check for an overrun after the fact. @@ -214,7 +210,7 @@ bool AudioEncoderDecoderIsacT::EncodeInternal(uint32_t rtp_timestamp, info->encoded_bytes = r; if (r == 0) - return true; + return; // Got enough input to produce a packet. Return the saved timestamp from // the first chunk of input that went into the packet. @@ -223,7 +219,7 @@ bool AudioEncoderDecoderIsacT::EncodeInternal(uint32_t rtp_timestamp, info->payload_type = payload_type_; if (!T::has_redundant_encoder) - return true; + return; if (redundant_length_bytes_ == 0) { // Do not emit the first output frame when using redundant encoding. @@ -260,7 +256,6 @@ bool AudioEncoderDecoderIsacT::EncodeInternal(uint32_t rtp_timestamp, DCHECK_LE(redundant_length_bytes_, sizeof(redundant_payload_)); DCHECK_GE(redundant_length_bytes_, 0u); last_encoded_timestamp_ = packet_timestamp_; - return true; } template diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc b/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc index 48d7ae703..03725230a 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc @@ -51,11 +51,10 @@ TEST(AudioEncoderIsacRedTest, CompareRedAndNoRed) { EXPECT_EQ(0u, red_info.encoded_bytes); EXPECT_EQ(0u, red_info.redundant.size()); const uint32_t timestamp = static_cast(i); - EXPECT_TRUE(isac_encoder.Encode(timestamp, input, k10MsSamples, - kMaxEncodedSizeBytes, encoded, &info)); - EXPECT_TRUE(isac_red_encoder.Encode(timestamp, input, k10MsSamples, - kMaxEncodedSizeBytes, red_encoded, - &red_info)); + isac_encoder.Encode(timestamp, input, k10MsSamples, kMaxEncodedSizeBytes, + encoded, &info); + isac_red_encoder.Encode(timestamp, input, k10MsSamples, + kMaxEncodedSizeBytes, red_encoded, &red_info); } EXPECT_GT(info.encoded_bytes, 0u) << "Regular codec did not produce any output"; diff --git a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h index e424bc6c2..70ee49745 100644 --- a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h +++ b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h @@ -29,7 +29,7 @@ class MockAudioEncoder : public AudioEncoder { MOCK_METHOD1(SetProjectedPacketLossRate, void(double)); // Note, we explicitly chose not to create a mock for the Encode method. MOCK_METHOD5(EncodeInternal, - bool(uint32_t timestamp, + void(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, 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 25256bcaa..688fb6405 100644 --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -166,7 +166,7 @@ void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) { } } -bool AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, @@ -178,7 +178,7 @@ bool AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp, if (input_buffer_.size() < (static_cast(num_10ms_frames_per_packet_) * samples_per_10ms_frame_)) { info->encoded_bytes = 0; - return true; + return; } CHECK_EQ(input_buffer_.size(), static_cast(num_10ms_frames_per_packet_) * @@ -193,7 +193,6 @@ bool AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp, info->encoded_bytes = r; info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; - return true; } } // namespace webrtc diff --git a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h index d330eeba7..e2ad601e6 100644 --- a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h +++ b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h @@ -54,7 +54,7 @@ class AudioEncoderOpus final : public AudioEncoder { ApplicationMode application() const { return application_; } protected: - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc index c1ffa5352..afc6391da 100644 --- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -56,14 +56,14 @@ void AudioEncoderCopyRed::SetProjectedPacketLossRate(double fraction) { speech_encoder_->SetProjectedPacketLossRate(fraction); } -bool AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp, +void AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, EncodedInfo* info) { - CHECK(speech_encoder_->Encode(rtp_timestamp, audio, - static_cast(SampleRateHz() / 100), - max_encoded_bytes, encoded, info)); + speech_encoder_->Encode(rtp_timestamp, audio, + static_cast(SampleRateHz() / 100), + max_encoded_bytes, encoded, info); CHECK_GE(max_encoded_bytes, info->encoded_bytes + secondary_info_.encoded_bytes); CHECK(info->redundant.empty()) << "Cannot use nested redundant encoders."; @@ -97,7 +97,6 @@ bool AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp, it != info->redundant.end(); ++it) { info->encoded_bytes += it->encoded_bytes; } - return true; } } // namespace webrtc diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h index 4414d04af..beea1cf9f 100644 --- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h +++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h @@ -44,7 +44,7 @@ class AudioEncoderCopyRed : public AudioEncoder { void SetProjectedPacketLossRate(double fraction) override; protected: - virtual bool EncodeInternal(uint32_t rtp_timestamp, + virtual void EncodeInternal(uint32_t rtp_timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc index 56ada5f88..b3a76a5c0 100644 --- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc @@ -57,8 +57,8 @@ class AudioEncoderCopyRedTest : public ::testing::Test { void Encode() { ASSERT_TRUE(red_.get() != NULL); encoded_info_ = AudioEncoder::EncodedInfo(); - ASSERT_TRUE(red_->Encode(timestamp_, audio_, num_audio_samples_10ms, - kMaxEncodedBytes, encoded_, &encoded_info_)); + red_->Encode(timestamp_, audio_, num_audio_samples_10ms, + kMaxEncodedBytes, encoded_, &encoded_info_); timestamp_ += num_audio_samples_10ms; } @@ -79,7 +79,7 @@ class MockEncodeHelper { memset(&info_, 0, sizeof(info_)); } - bool Encode(uint32_t timestamp, + void Encode(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, @@ -91,7 +91,6 @@ class MockEncodeHelper { } CHECK(info); *info = info_; - return true; } AudioEncoder::EncodedInfo info_; @@ -141,8 +140,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) { InSequence s; MockFunction check; for (int i = 1; i <= 6; ++i) { - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(Return(true)); + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)); EXPECT_CALL(check, Call(i)); Encode(); check.Call(i); @@ -157,7 +155,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckNoOuput) { AudioEncoder::EncodedInfo info; info.encoded_bytes = kEncodedSize; EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); Encode(); // First call is a special case, since it does not include a secondary // payload. @@ -167,14 +165,14 @@ TEST_F(AudioEncoderCopyRedTest, CheckNoOuput) { // Next call to the speech encoder will not produce any output. info.encoded_bytes = 0; EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); Encode(); EXPECT_EQ(0u, encoded_info_.encoded_bytes); // Final call to the speech encoder will produce output. info.encoded_bytes = kEncodedSize; EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); Encode(); EXPECT_EQ(2 * kEncodedSize, encoded_info_.encoded_bytes); ASSERT_EQ(2u, encoded_info_.redundant.size()); @@ -191,7 +189,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) { AudioEncoder::EncodedInfo info; info.encoded_bytes = encode_size; EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); + .WillOnce(SetArgPointee<4>(info)); } // First call is a special case, since it does not include a secondary diff --git a/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc b/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc index 71df8a386..d40615bc2 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc @@ -236,9 +236,9 @@ int16_t ACMGenericCodec::Encode(uint8_t* bitstream, AudioEncoder::EncodedInfo* encoded_info) { WriteLockScoped wl(codec_wrapper_lock_); CHECK(!input_.empty()); - CHECK(encoder_->Encode(rtp_timestamp_, &input_[0], - input_.size() / encoder_->NumChannels(), - 2 * MAX_PAYLOAD_SIZE_BYTE, bitstream, encoded_info)); + encoder_->Encode(rtp_timestamp_, &input_[0], + input_.size() / encoder_->NumChannels(), + 2 * MAX_PAYLOAD_SIZE_BYTE, bitstream, encoded_info); input_.clear(); *bitstream_len_byte = static_cast(encoded_info->encoded_bytes); *timestamp = encoded_info->encoded_timestamp; diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc index 4c326cc84..e8823b3e5 100644 --- a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -150,9 +150,9 @@ class AudioDecoderTest : public ::testing::Test { samples_per_10ms, channels_, interleaved_input.get()); - EXPECT_TRUE(audio_encoder_->Encode( - 0, interleaved_input.get(), audio_encoder_->SampleRateHz() / 100, - data_length_ * 2, output, &encoded_info_)); + audio_encoder_->Encode(0, interleaved_input.get(), + audio_encoder_->SampleRateHz() / 100, + data_length_ * 2, output, &encoded_info_); } EXPECT_EQ(payload_type_, encoded_info_.payload_type); return static_cast(encoded_info_.encoded_bytes);