From 3b79daff14127f3adb19b16d94336d44ff49e841 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Fri, 12 Dec 2014 13:31:24 +0000 Subject: [PATCH] Moving encoded_bytes into EncodedInfo BUG=3926 R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/35469004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7883 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_coding/codecs/audio_encoder.h | 8 +-- .../codecs/cng/audio_encoder_cng.cc | 13 ++-- .../codecs/cng/audio_encoder_cng_unittest.cc | 60 +++++++++---------- .../codecs/cng/include/audio_encoder_cng.h | 2 - .../codecs/g711/audio_encoder_pcm.cc | 5 +- .../codecs/g711/include/audio_encoder_pcm.h | 1 - .../codecs/g722/audio_encoder_g722.cc | 5 +- .../codecs/g722/include/audio_encoder_g722.h | 1 - .../codecs/ilbc/audio_encoder_ilbc.cc | 5 +- .../ilbc/interface/audio_encoder_ilbc.h | 1 - .../isac/main/interface/audio_encoder_isac.h | 1 - .../isac/main/source/audio_encoder_isac.cc | 3 +- .../codecs/mock/mock_audio_encoder.h | 3 +- .../codecs/opus/audio_encoder_opus.cc | 5 +- .../opus/interface/audio_encoder_opus.h | 1 - .../neteq/audio_decoder_unittest.cc | 8 +-- 16 files changed, 53 insertions(+), 69 deletions(-) diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.h b/webrtc/modules/audio_coding/codecs/audio_encoder.h index 615e428bb..27b9f2ffd 100644 --- a/webrtc/modules/audio_coding/codecs/audio_encoder.h +++ b/webrtc/modules/audio_coding/codecs/audio_encoder.h @@ -23,6 +23,9 @@ namespace webrtc { class AudioEncoder { public: struct EncodedInfo { + EncodedInfo() : encoded_bytes(0), encoded_timestamp(0), payload_type(0) {} + + size_t encoded_bytes; uint32_t encoded_timestamp; int payload_type; }; @@ -41,7 +44,6 @@ class AudioEncoder { size_t num_samples_per_channel, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { CHECK_EQ(num_samples_per_channel, static_cast(sample_rate_hz() / 100)); @@ -49,9 +51,8 @@ class AudioEncoder { audio, max_encoded_bytes, encoded, - encoded_bytes, info); - CHECK_LE(*encoded_bytes, max_encoded_bytes); + CHECK_LE(info->encoded_bytes, max_encoded_bytes); return ret; } @@ -76,7 +77,6 @@ class AudioEncoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) = 0; }; 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 864dc8aaf..9cf909829 100644 --- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc +++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc @@ -90,13 +90,12 @@ bool AudioEncoderCng::EncodeInternal(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, 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; } - *encoded_bytes = 0; + info->encoded_bytes = 0; const int num_samples = sample_rate_hz() / 100 * num_channels(); if (speech_buffer_.empty()) { CHECK_EQ(frames_in_buffer_, 0); @@ -143,15 +142,14 @@ bool AudioEncoderCng::EncodeInternal(uint32_t timestamp, bool return_val = true; switch (activity) { case Vad::kPassive: { - return_val = EncodePassive(encoded, encoded_bytes); + return_val = EncodePassive(encoded, &info->encoded_bytes); info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = cng_payload_type_; last_frame_active_ = false; break; } case Vad::kActive: { - return_val = - EncodeActive(max_encoded_bytes, encoded, encoded_bytes, info); + return_val = EncodeActive(max_encoded_bytes, encoded, info); last_frame_active_ = true; break; } @@ -190,17 +188,16 @@ bool AudioEncoderCng::EncodePassive(uint8_t* encoded, size_t* encoded_bytes) { bool AudioEncoderCng::EncodeActive(size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { const size_t samples_per_10ms_frame = 10 * sample_rate_hz_ / 1000; for (int i = 0; i < frames_in_buffer_; ++i) { if (!speech_encoder_->Encode(first_timestamp_in_buffer_, &speech_buffer_[i * samples_per_10ms_frame], samples_per_10ms_frame, max_encoded_bytes, - encoded, encoded_bytes, info)) + encoded, info)) return false; if (i < frames_in_buffer_ - 1) { - CHECK_EQ(*encoded_bytes, 0u) << "Encoder delivered data too early."; + CHECK_EQ(info->encoded_bytes, 0u) << "Encoder delivered data too early."; } } return true; 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 6262fd20c..76b9fc088 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 @@ -18,6 +18,7 @@ using ::testing::Return; using ::testing::_; using ::testing::SetArgPointee; using ::testing::InSequence; +using ::testing::Invoke; namespace webrtc { @@ -33,8 +34,7 @@ class AudioEncoderCngTest : public ::testing::Test { AudioEncoderCngTest() : mock_vad_(new MockVad(Vad::kVadNormal)), timestamp_(4711), - num_audio_samples_10ms_(0), - encoded_bytes_(0) { + num_audio_samples_10ms_(0) { memset(encoded_, 0, kMaxEncodedBytes); memset(audio_, 0, kMaxNumSamples * 2); config_.speech_encoder = &mock_encoder_; @@ -70,11 +70,9 @@ class AudioEncoderCngTest : public ::testing::Test { void Encode() { ASSERT_TRUE(cng_) << "Must call CreateCng() first."; - memset(&encoded_info_, 0, sizeof(encoded_info_)); - encoded_bytes_ = 0; + encoded_info_ = AudioEncoder::EncodedInfo(); ASSERT_TRUE(cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, - kMaxEncodedBytes, encoded_, &encoded_bytes_, - &encoded_info_)); + kMaxEncodedBytes, encoded_, &encoded_info_)); timestamp_ += num_audio_samples_10ms_; } @@ -89,30 +87,31 @@ class AudioEncoderCngTest : public ::testing::Test { .WillRepeatedly(Return(active_speech ? Vad::kActive : Vad::kPassive)); // Don't expect any calls to the encoder yet. - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)).Times(0); for (int i = 0; i < blocks_per_frame - 1; ++i) { Encode(); - EXPECT_EQ(0u, encoded_bytes_); + EXPECT_EQ(0u, encoded_info_.encoded_bytes); } + AudioEncoder::EncodedInfo info; if (active_speech) { // Now expect |blocks_per_frame| calls to the encoder in sequence. // Let the speech codec mock return true and set the number of encoded // bytes to |kMockReturnEncodedBytes|. InSequence s; for (int j = 0; j < blocks_per_frame - 1; ++j) { - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(0), Return(true))); + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) + .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); } - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)) - .WillOnce( - DoAll(SetArgPointee<4>(kMockReturnEncodedBytes), Return(true))); + info.encoded_bytes = kMockReturnEncodedBytes; + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) + .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); } Encode(); if (active_speech) { - EXPECT_EQ(kMockReturnEncodedBytes, encoded_bytes_); + EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes); } else { EXPECT_EQ(static_cast(config_.num_cng_coefficients + 1), - encoded_bytes_); + encoded_info_.encoded_bytes); } } @@ -184,7 +183,6 @@ class AudioEncoderCngTest : public ::testing::Test { int16_t audio_[kMaxNumSamples]; size_t num_audio_samples_10ms_; uint8_t encoded_[kMaxEncodedBytes]; - size_t encoded_bytes_; AudioEncoder::EncodedInfo encoded_info_; }; @@ -239,7 +237,7 @@ TEST_F(AudioEncoderCngTest, EncodePassive) { EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) .WillRepeatedly(Return(Vad::kPassive)); // Expect no calls at all to the speech encoder mock. - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)).Times(0); uint32_t expected_timestamp = timestamp_; for (int i = 0; i < 100; ++i) { Encode(); @@ -251,13 +249,13 @@ TEST_F(AudioEncoderCngTest, EncodePassive) { // If so, verify that we got a CNG encoding. EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); EXPECT_EQ(static_cast(config_.num_cng_coefficients) + 1, - encoded_bytes_); + encoded_info_.encoded_bytes); EXPECT_EQ(expected_timestamp, encoded_info_.encoded_timestamp); } expected_timestamp += kBlocksPerFrame * num_audio_samples_10ms_; } else { // Otherwise, expect no output. - EXPECT_EQ(0u, encoded_bytes_); + EXPECT_EQ(0u, encoded_info_.encoded_bytes); } } } @@ -268,19 +266,19 @@ TEST_F(AudioEncoderCngTest, MixedActivePassive) { CreateCng(); // All of the frame is active speech. - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)) + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) .Times(6) .WillRepeatedly(Return(true)); EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kActive)); // First half of the frame is active speech. - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)) + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) .Times(6) .WillRepeatedly(Return(true)); EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kPassive)); // Second half of the frame is active speech. - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)) + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) .Times(6) .WillRepeatedly(Return(true)); EXPECT_TRUE(CheckMixedActivePassive(Vad::kPassive, Vad::kActive)); @@ -324,7 +322,7 @@ TEST_F(AudioEncoderCngTest, VadInputSize60Ms) { // speech encoder. TEST_F(AudioEncoderCngTest, VerifyEncoderInfoPropagation) { CreateCng(); - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, &encoded_info_)) + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, &encoded_info_)) .WillOnce(Return(true)); EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1)); EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) @@ -335,7 +333,7 @@ TEST_F(AudioEncoderCngTest, VerifyEncoderInfoPropagation) { // Verifies that the correct payload type is set when CNG is encoded. TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) { CreateCng(); - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)).Times(0); EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1)); EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) .WillOnce(Return(Vad::kPassive)); @@ -357,20 +355,22 @@ TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) { Encode(); EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); EXPECT_EQ(static_cast(config_.num_cng_coefficients) + 1, - encoded_bytes_); + encoded_info_.encoded_bytes); // Encode again, and make sure we got no frame at all (since the SID frame // period is 100 ms by default). Encode(); - EXPECT_EQ(0u, encoded_bytes_); + EXPECT_EQ(0u, encoded_info_.encoded_bytes); // Now encode active speech. encoded_info_.payload_type = 0; EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) .WillOnce(Return(Vad::kActive)); - EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _, _)) - .WillOnce(DoAll(SetArgPointee<4>(kMockReturnEncodedBytes), Return(true))); + AudioEncoder::EncodedInfo info; + info.encoded_bytes = kMockReturnEncodedBytes; + EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _)) + .WillOnce(DoAll(SetArgPointee<4>(info), Return(true))); Encode(); - EXPECT_EQ(kMockReturnEncodedBytes, encoded_bytes_); + EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes); // Go back to noise again, and verify that a SID frame is emitted. EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) @@ -378,7 +378,7 @@ TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) { Encode(); EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); EXPECT_EQ(static_cast(config_.num_cng_coefficients) + 1, - encoded_bytes_); + encoded_info_.encoded_bytes); } #if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 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 c74441372..884c0474b 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 @@ -57,7 +57,6 @@ class AudioEncoderCng : public AudioEncoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) OVERRIDE; private: @@ -71,7 +70,6 @@ class AudioEncoderCng : public AudioEncoder { bool EncodeActive(size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info); AudioEncoder* speech_encoder_; 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 1d1be4ca2..7f7b77ec7 100644 --- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc +++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc @@ -63,7 +63,6 @@ bool AudioEncoderPcm::EncodeInternal(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { const int num_samples = sample_rate_hz() / 100 * num_channels(); if (speech_buffer_.empty()) { @@ -73,7 +72,7 @@ bool AudioEncoderPcm::EncodeInternal(uint32_t timestamp, speech_buffer_.push_back(audio[i]); } if (speech_buffer_.size() < static_cast(full_frame_samples_)) { - *encoded_bytes = 0; + info->encoded_bytes = 0; return true; } CHECK_EQ(speech_buffer_.size(), static_cast(full_frame_samples_)); @@ -83,7 +82,7 @@ bool AudioEncoderPcm::EncodeInternal(uint32_t timestamp, info->payload_type = payload_type_; if (ret < 0) return false; - *encoded_bytes = static_cast(ret); + info->encoded_bytes = static_cast(ret); return true; } 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 a1c3c9ecc..93748b354 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 @@ -44,7 +44,6 @@ class AudioEncoderPcm : public AudioEncoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) OVERRIDE; virtual int16_t EncodeCall(const int16_t* audio, 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 0b055202a..c483f44cb 100644 --- a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc +++ b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc @@ -68,7 +68,6 @@ bool AudioEncoderG722::EncodeInternal(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { const int samples_per_channel = kSampleRateHz / 100 * num_10ms_frames_per_packet_; @@ -86,7 +85,7 @@ bool AudioEncoderG722::EncodeInternal(uint32_t 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_) { - *encoded_bytes = 0; + info->encoded_bytes = 0; return true; } @@ -115,7 +114,7 @@ bool AudioEncoderG722::EncodeInternal(uint32_t timestamp, encoded[i * num_channels_ + j] = interleave_buffer_[2 * j] << 4 | interleave_buffer_[2 * j + 1]; } - *encoded_bytes = samples_per_channel / 2 * num_channels_; + info->encoded_bytes = samples_per_channel / 2 * num_channels_; info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; return true; 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 12e900160..25fa37bd7 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 @@ -40,7 +40,6 @@ class AudioEncoderG722 : public AudioEncoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) OVERRIDE; private: 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 4dcef3b9a..d7dfdbc8e 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,6 @@ bool AudioEncoderIlbc::EncodeInternal(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { const size_t expected_output_len = num_10ms_frames_per_packet_ == 2 ? 38 : 50; @@ -74,7 +73,7 @@ bool AudioEncoderIlbc::EncodeInternal(uint32_t 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_) { - *encoded_bytes = 0; + info->encoded_bytes = 0; return true; } @@ -89,7 +88,7 @@ bool AudioEncoderIlbc::EncodeInternal(uint32_t timestamp, if (output_len == -1) return false; // Encoding error. DCHECK_EQ(output_len, static_cast(expected_output_len)); - *encoded_bytes = output_len; + info->encoded_bytes = output_len; info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; return true; 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 fa9730b00..0639c9458 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 @@ -39,7 +39,6 @@ class AudioEncoderIlbc : public AudioEncoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) OVERRIDE; private: diff --git a/webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h b/webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h index bf53b28fc..e111a57d9 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h +++ b/webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h @@ -87,7 +87,6 @@ class AudioEncoderDecoderIsac : public AudioEncoder, public AudioDecoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) OVERRIDE; private: diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac.cc b/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac.cc index 79e75e27b..c80104aff 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac.cc +++ b/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac.cc @@ -111,7 +111,6 @@ bool AudioEncoderDecoderIsac::EncodeInternal(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { if (!packet_in_progress_) { // Starting a new packet; remember the timestamp for later. @@ -133,7 +132,7 @@ bool AudioEncoderDecoderIsac::EncodeInternal(uint32_t timestamp, // buffer. All we can do is check for an overrun after the fact. CHECK(static_cast(r) <= max_encoded_bytes); - *encoded_bytes = r; + info->encoded_bytes = r; if (r > 0) { // Got enough input to produce a packet. Return the saved timestamp from // the first chunk of input that went into the packet. 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 fe2ace95b..fd7696e97 100644 --- a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h +++ b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h @@ -26,12 +26,11 @@ class MockAudioEncoder : public AudioEncoder { MOCK_CONST_METHOD0(Num10MsFramesInNextPacket, int()); MOCK_CONST_METHOD0(Max10MsFramesInAPacket, int()); // Note, we explicitly chose not to create a mock for the Encode method. - MOCK_METHOD6(EncodeInternal, + MOCK_METHOD5(EncodeInternal, bool(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info)); }; 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 d58a8f1be..1cfc30219 100644 --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -82,7 +82,6 @@ bool AudioEncoderOpus::EncodeInternal(uint32_t timestamp, const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) { if (input_buffer_.empty()) first_timestamp_in_buffer_ = timestamp; @@ -90,7 +89,7 @@ bool AudioEncoderOpus::EncodeInternal(uint32_t timestamp, audio + samples_per_10ms_frame_); if (input_buffer_.size() < (static_cast(num_10ms_frames_per_packet_) * samples_per_10ms_frame_)) { - *encoded_bytes = 0; + info->encoded_bytes = 0; return true; } CHECK_EQ(input_buffer_.size(), @@ -103,7 +102,7 @@ bool AudioEncoderOpus::EncodeInternal(uint32_t timestamp, input_buffer_.clear(); if (r < 0) return false; - *encoded_bytes = r; + info->encoded_bytes = r; info->encoded_timestamp = first_timestamp_in_buffer_; info->payload_type = payload_type_; return true; 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 c404b5816..f44627dc4 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 @@ -41,7 +41,6 @@ class AudioEncoderOpus : public AudioEncoder { const int16_t* audio, size_t max_encoded_bytes, uint8_t* encoded, - size_t* encoded_bytes, EncodedInfo* info) OVERRIDE; private: diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc index 63803ad21..5a2c4ba5f 100644 --- a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -135,14 +135,14 @@ class AudioDecoderTest : public ::testing::Test { virtual int EncodeFrame(const int16_t* input, size_t input_len_samples, uint8_t* output) { - size_t enc_len_bytes = 0; + encoded_info_.encoded_bytes = 0; const size_t samples_per_10ms = audio_encoder_->sample_rate_hz() / 100; CHECK_EQ(samples_per_10ms * audio_encoder_->Num10MsFramesInNextPacket(), input_len_samples); scoped_ptr interleaved_input( new int16_t[channels_ * samples_per_10ms]); for (int i = 0; i < audio_encoder_->Num10MsFramesInNextPacket(); ++i) { - EXPECT_EQ(0u, enc_len_bytes); + EXPECT_EQ(0u, encoded_info_.encoded_bytes); // Duplicate the mono input signal to however many channels the test // wants. @@ -152,10 +152,10 @@ class AudioDecoderTest : public ::testing::Test { EXPECT_TRUE(audio_encoder_->Encode( 0, interleaved_input.get(), audio_encoder_->sample_rate_hz() / 100, - data_length_ * 2, output, &enc_len_bytes, &encoded_info_)); + data_length_ * 2, output, &encoded_info_)); } EXPECT_EQ(payload_type_, encoded_info_.payload_type); - return static_cast(enc_len_bytes); + return static_cast(encoded_info_.encoded_bytes); } // Encodes and decodes audio. The absolute difference between the input and