Renamed new EncodeInternal to EncodeImpl to ensure proper backwards compatibility.
Renamed the new variant of EncodeInternal to EncodeImpl, so that subclasses implementing one of the EncodeInternal don't need to explicitly contain 'using AudioEncoder::EncodeInternal' to avoid their implementation hiding the other variant of EncodeInternal. This causes a warning (treated as an error) when building using GCC. Review URL: https://codereview.webrtc.org/1764583003 Cr-Commit-Position: refs/heads/master@{#11868}
This commit is contained in:
@ -1648,7 +1648,7 @@ TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) {
|
|||||||
EXPECT_CALL(mock_encoder, GetTargetBitrate())
|
EXPECT_CALL(mock_encoder, GetTargetBitrate())
|
||||||
.Times(AtLeast(1))
|
.Times(AtLeast(1))
|
||||||
.WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate));
|
.WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate));
|
||||||
EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder, EncodeImpl(_, _, _))
|
||||||
.Times(AtLeast(1))
|
.Times(AtLeast(1))
|
||||||
.WillRepeatedly(Invoke(&encoder,
|
.WillRepeatedly(Invoke(&encoder,
|
||||||
static_cast<
|
static_cast<
|
||||||
|
|||||||
@ -122,14 +122,14 @@ TEST(RentACodecTest, ExternalEncoder) {
|
|||||||
::testing::InSequence s;
|
::testing::InSequence s;
|
||||||
info.encoded_timestamp = 0;
|
info.encoded_timestamp = 0;
|
||||||
EXPECT_CALL(external_encoder,
|
EXPECT_CALL(external_encoder,
|
||||||
EncodeInternal(0, rtc::ArrayView<const int16_t>(audio),
|
EncodeImpl(0, rtc::ArrayView<const int16_t>(audio),
|
||||||
&encoded))
|
&encoded))
|
||||||
.WillOnce(Return(info));
|
.WillOnce(Return(info));
|
||||||
EXPECT_CALL(external_encoder, Mark("A"));
|
EXPECT_CALL(external_encoder, Mark("A"));
|
||||||
EXPECT_CALL(external_encoder, Mark("B"));
|
EXPECT_CALL(external_encoder, Mark("B"));
|
||||||
info.encoded_timestamp = 2;
|
info.encoded_timestamp = 2;
|
||||||
EXPECT_CALL(external_encoder,
|
EXPECT_CALL(external_encoder,
|
||||||
EncodeInternal(2, rtc::ArrayView<const int16_t>(audio),
|
EncodeImpl(2, rtc::ArrayView<const int16_t>(audio),
|
||||||
&encoded))
|
&encoded))
|
||||||
.WillOnce(Return(info));
|
.WillOnce(Return(info));
|
||||||
EXPECT_CALL(external_encoder, Die());
|
EXPECT_CALL(external_encoder, Die());
|
||||||
|
|||||||
@ -32,7 +32,7 @@ AudioEncoder::EncodedInfo AudioEncoder::Encode(
|
|||||||
static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
|
static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
|
||||||
|
|
||||||
const size_t old_size = encoded->size();
|
const size_t old_size = encoded->size();
|
||||||
EncodedInfo info = EncodeInternal(rtp_timestamp, audio, encoded);
|
EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded);
|
||||||
RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
|
RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ AudioEncoder::EncodedInfo AudioEncoder::DEPRECATED_Encode(
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoder::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoder::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded)
|
rtc::Buffer* encoded)
|
||||||
@ -80,7 +80,7 @@ AudioEncoder::EncodedInfo AudioEncoder::EncodeInternal(
|
|||||||
uint8_t* encoded)
|
uint8_t* encoded)
|
||||||
{
|
{
|
||||||
rtc::Buffer temp_buffer;
|
rtc::Buffer temp_buffer;
|
||||||
EncodedInfo info = EncodeInternal(rtp_timestamp, audio, &temp_buffer);
|
EncodedInfo info = EncodeImpl(rtp_timestamp, audio, &temp_buffer);
|
||||||
RTC_DCHECK_LE(temp_buffer.size(), max_encoded_bytes);
|
RTC_DCHECK_LE(temp_buffer.size(), max_encoded_bytes);
|
||||||
std::memcpy(encoded, temp_buffer.data(), info.encoded_bytes);
|
std::memcpy(encoded, temp_buffer.data(), info.encoded_bytes);
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class AudioEncoder {
|
|||||||
// NumChannels() samples). Multi-channel audio must be sample-interleaved.
|
// NumChannels() samples). Multi-channel audio must be sample-interleaved.
|
||||||
// The encoder appends zero or more bytes of output to |encoded| and returns
|
// The encoder appends zero or more bytes of output to |encoded| and returns
|
||||||
// additional encoding information. Encode() checks some preconditions, calls
|
// additional encoding information. Encode() checks some preconditions, calls
|
||||||
// EncodeInternal() which does the actual work, and then checks some
|
// EncodeImpl() which does the actual work, and then checks some
|
||||||
// postconditions.
|
// postconditions.
|
||||||
EncodedInfo Encode(uint32_t rtp_timestamp,
|
EncodedInfo Encode(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
@ -110,12 +110,12 @@ class AudioEncoder {
|
|||||||
size_t max_encoded_bytes,
|
size_t max_encoded_bytes,
|
||||||
uint8_t* encoded);
|
uint8_t* encoded);
|
||||||
|
|
||||||
// Deprecated interface of EncodeInternal (also bug 5591). May incur a copy.
|
// Deprecated interface EncodeInternal (see bug 5591). May incur a copy.
|
||||||
// Subclasses implement this to perform the actual encoding. Called by
|
// Subclasses implement this to perform the actual encoding. Called by
|
||||||
// Encode(). By default, this is implemented as a call to the newer
|
// Encode(). By default, this is implemented as a call to the newer
|
||||||
// EncodeInternal() that accepts an rtc::Buffer instead of a raw pointer.
|
// EncodeImpl() that accepts an rtc::Buffer instead of a raw pointer.
|
||||||
// That version is protected, so see below. At least one of the two
|
// That version is protected, so see below. At least one of EncodeInternal
|
||||||
// interfaces of EncodeInternal _must_ be implemented by a subclass.
|
// or EncodeImpl _must_ be implemented by a subclass.
|
||||||
virtual EncodedInfo EncodeInternal(
|
virtual EncodedInfo EncodeInternal(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
@ -163,12 +163,12 @@ class AudioEncoder {
|
|||||||
protected:
|
protected:
|
||||||
// Subclasses implement this to perform the actual encoding. Called by
|
// Subclasses implement this to perform the actual encoding. Called by
|
||||||
// Encode(). For compatibility reasons, this is implemented by default as a
|
// Encode(). For compatibility reasons, this is implemented by default as a
|
||||||
// call to the older version of EncodeInternal(). At least one of the two
|
// call to the older interface EncodeInternal(). At least one of
|
||||||
// interfaces of EncodeInternal _must_ be implemented by a subclass.
|
// EncodeInternal or EncodeImpl _must_ be implemented by a
|
||||||
// Preferably this one.
|
// subclass. Preferably this one.
|
||||||
virtual EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded);
|
rtc::Buffer* encoded);
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_
|
||||||
|
|||||||
@ -37,7 +37,7 @@ TEST(AudioEncoderTest, EncodeInternalRedirectsOk) {
|
|||||||
EXPECT_CALL(old_impl, EncodeInternal(_, _, _, _)).WillOnce(
|
EXPECT_CALL(old_impl, EncodeInternal(_, _, _, _)).WillOnce(
|
||||||
Invoke(MockAudioEncoderDeprecated::CopyEncoding(payload)));
|
Invoke(MockAudioEncoderDeprecated::CopyEncoding(payload)));
|
||||||
|
|
||||||
EXPECT_CALL(new_impl, EncodeInternal(_, _, _)).WillOnce(
|
EXPECT_CALL(new_impl, EncodeImpl(_, _, _)).WillOnce(
|
||||||
Invoke(MockAudioEncoder::CopyEncoding(payload)));
|
Invoke(MockAudioEncoder::CopyEncoding(payload)));
|
||||||
|
|
||||||
int16_t audio[80];
|
int16_t audio[80];
|
||||||
|
|||||||
@ -97,7 +97,7 @@ int AudioEncoderCng::GetTargetBitrate() const {
|
|||||||
return speech_encoder_->GetTargetBitrate();
|
return speech_encoder_->GetTargetBitrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderCng::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -30,8 +30,6 @@ class Vad;
|
|||||||
|
|
||||||
class AudioEncoderCng final : public AudioEncoder {
|
class AudioEncoderCng final : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
|
|
||||||
@ -59,9 +57,9 @@ class AudioEncoderCng final : public AudioEncoder {
|
|||||||
size_t Num10MsFramesInNextPacket() const override;
|
size_t Num10MsFramesInNextPacket() const override;
|
||||||
size_t Max10MsFramesInAPacket() const override;
|
size_t Max10MsFramesInAPacket() const override;
|
||||||
int GetTargetBitrate() const override;
|
int GetTargetBitrate() const override;
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
bool SetFec(bool enable) override;
|
bool SetFec(bool enable) override;
|
||||||
bool SetDtx(bool enable) override;
|
bool SetDtx(bool enable) override;
|
||||||
|
|||||||
@ -88,11 +88,11 @@ class AudioEncoderCngTest : public ::testing::Test {
|
|||||||
InSequence s;
|
InSequence s;
|
||||||
AudioEncoder::EncodedInfo info;
|
AudioEncoder::EncodedInfo info;
|
||||||
for (size_t j = 0; j < num_calls - 1; ++j) {
|
for (size_t j = 0; j < num_calls - 1; ++j) {
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Return(info));
|
.WillOnce(Return(info));
|
||||||
}
|
}
|
||||||
info.encoded_bytes = kMockReturnEncodedBytes;
|
info.encoded_bytes = kMockReturnEncodedBytes;
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(
|
.WillOnce(Invoke(
|
||||||
MockAudioEncoder::FakeEncoding(kMockReturnEncodedBytes)));
|
MockAudioEncoder::FakeEncoding(kMockReturnEncodedBytes)));
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ class AudioEncoderCngTest : public ::testing::Test {
|
|||||||
.WillRepeatedly(Return(active_speech ? Vad::kActive : Vad::kPassive));
|
.WillRepeatedly(Return(active_speech ? Vad::kActive : Vad::kPassive));
|
||||||
|
|
||||||
// Don't expect any calls to the encoder yet.
|
// Don't expect any calls to the encoder yet.
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).Times(0);
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)).Times(0);
|
||||||
for (size_t i = 0; i < blocks_per_frame - 1; ++i) {
|
for (size_t i = 0; i < blocks_per_frame - 1; ++i) {
|
||||||
Encode();
|
Encode();
|
||||||
EXPECT_EQ(0u, encoded_info_.encoded_bytes);
|
EXPECT_EQ(0u, encoded_info_.encoded_bytes);
|
||||||
@ -259,7 +259,7 @@ TEST_F(AudioEncoderCngTest, EncodePassive) {
|
|||||||
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
|
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
|
||||||
.WillRepeatedly(Return(Vad::kPassive));
|
.WillRepeatedly(Return(Vad::kPassive));
|
||||||
// Expect no calls at all to the speech encoder mock.
|
// Expect no calls at all to the speech encoder mock.
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).Times(0);
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)).Times(0);
|
||||||
uint32_t expected_timestamp = timestamp_;
|
uint32_t expected_timestamp = timestamp_;
|
||||||
for (size_t i = 0; i < 100; ++i) {
|
for (size_t i = 0; i < 100; ++i) {
|
||||||
Encode();
|
Encode();
|
||||||
@ -341,7 +341,7 @@ TEST_F(AudioEncoderCngTest, VadInputSize60Ms) {
|
|||||||
// Verifies that the correct payload type is set when CNG is encoded.
|
// Verifies that the correct payload type is set when CNG is encoded.
|
||||||
TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) {
|
TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) {
|
||||||
CreateCng();
|
CreateCng();
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).Times(0);
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)).Times(0);
|
||||||
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1U));
|
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1U));
|
||||||
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
|
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
|
||||||
.WillOnce(Return(Vad::kPassive));
|
.WillOnce(Return(Vad::kPassive));
|
||||||
@ -373,7 +373,7 @@ TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) {
|
|||||||
encoded_info_.payload_type = 0;
|
encoded_info_.payload_type = 0;
|
||||||
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
|
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
|
||||||
.WillOnce(Return(Vad::kActive));
|
.WillOnce(Return(Vad::kActive));
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).WillOnce(
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)).WillOnce(
|
||||||
Invoke(MockAudioEncoder::FakeEncoding(kMockReturnEncodedBytes)));
|
Invoke(MockAudioEncoder::FakeEncoding(kMockReturnEncodedBytes)));
|
||||||
Encode();
|
Encode();
|
||||||
EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes);
|
EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ int AudioEncoderPcm::GetTargetBitrate() const {
|
|||||||
8 * BytesPerSample() * SampleRateHz() * NumChannels());
|
8 * BytesPerSample() * SampleRateHz() * NumChannels());
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -20,8 +20,6 @@ namespace webrtc {
|
|||||||
|
|
||||||
class AudioEncoderPcm : public AudioEncoder {
|
class AudioEncoderPcm : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
public:
|
public:
|
||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
@ -48,9 +46,9 @@ class AudioEncoderPcm : public AudioEncoder {
|
|||||||
protected:
|
protected:
|
||||||
AudioEncoderPcm(const Config& config, int sample_rate_hz);
|
AudioEncoderPcm(const Config& config, int sample_rate_hz);
|
||||||
|
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
|
|
||||||
virtual size_t EncodeCall(const int16_t* audio,
|
virtual size_t EncodeCall(const int16_t* audio,
|
||||||
size_t input_len,
|
size_t input_len,
|
||||||
|
|||||||
@ -97,7 +97,7 @@ void AudioEncoderG722::Reset() {
|
|||||||
RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder));
|
RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder));
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderG722::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -23,8 +23,6 @@ struct CodecInst;
|
|||||||
|
|
||||||
class AudioEncoderG722 final : public AudioEncoder {
|
class AudioEncoderG722 final : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
|
|
||||||
@ -47,9 +45,9 @@ class AudioEncoderG722 final : public AudioEncoder {
|
|||||||
void Reset() override;
|
void Reset() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The encoder state for one channel.
|
// The encoder state for one channel.
|
||||||
|
|||||||
@ -89,7 +89,7 @@ int AudioEncoderIlbc::GetTargetBitrate() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -21,8 +21,6 @@ struct CodecInst;
|
|||||||
|
|
||||||
class AudioEncoderIlbc final : public AudioEncoder {
|
class AudioEncoderIlbc final : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
|
|
||||||
@ -42,9 +40,9 @@ class AudioEncoderIlbc final : public AudioEncoder {
|
|||||||
size_t Num10MsFramesInNextPacket() const override;
|
size_t Num10MsFramesInNextPacket() const override;
|
||||||
size_t Max10MsFramesInAPacket() const override;
|
size_t Max10MsFramesInAPacket() const override;
|
||||||
int GetTargetBitrate() const override;
|
int GetTargetBitrate() const override;
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -23,8 +23,6 @@ struct CodecInst;
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class AudioEncoderIsacT final : public AudioEncoder {
|
class AudioEncoderIsacT final : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
// Allowed combinations of sample rate, frame size, and bit rate are
|
// Allowed combinations of sample rate, frame size, and bit rate are
|
||||||
// - 16000 Hz, 30 ms, 10000-32000 bps
|
// - 16000 Hz, 30 ms, 10000-32000 bps
|
||||||
// - 16000 Hz, 60 ms, 10000-32000 bps
|
// - 16000 Hz, 60 ms, 10000-32000 bps
|
||||||
@ -62,9 +60,9 @@ class AudioEncoderIsacT final : public AudioEncoder {
|
|||||||
size_t Num10MsFramesInNextPacket() const override;
|
size_t Num10MsFramesInNextPacket() const override;
|
||||||
size_t Max10MsFramesInAPacket() const override;
|
size_t Max10MsFramesInAPacket() const override;
|
||||||
int GetTargetBitrate() const override;
|
int GetTargetBitrate() const override;
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -114,7 +114,7 @@ int AudioEncoderIsacT<T>::GetTargetBitrate() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -43,10 +43,8 @@ class MockAudioEncoderBase : public AudioEncoder {
|
|||||||
|
|
||||||
class MockAudioEncoder final : public MockAudioEncoderBase {
|
class MockAudioEncoder final : public MockAudioEncoderBase {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
// Note, we explicitly chose not to create a mock for the Encode method.
|
// Note, we explicitly chose not to create a mock for the Encode method.
|
||||||
MOCK_METHOD3(EncodeInternal,
|
MOCK_METHOD3(EncodeImpl,
|
||||||
EncodedInfo(uint32_t timestamp,
|
EncodedInfo(uint32_t timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded));
|
rtc::Buffer* encoded));
|
||||||
@ -96,8 +94,6 @@ class MockAudioEncoder final : public MockAudioEncoderBase {
|
|||||||
|
|
||||||
class MockAudioEncoderDeprecated final : public MockAudioEncoderBase {
|
class MockAudioEncoderDeprecated final : public MockAudioEncoderBase {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
// Note, we explicitly chose not to create a mock for the Encode method.
|
// Note, we explicitly chose not to create a mock for the Encode method.
|
||||||
MOCK_METHOD4(EncodeInternal,
|
MOCK_METHOD4(EncodeInternal,
|
||||||
EncodedInfo(uint32_t timestamp,
|
EncodedInfo(uint32_t timestamp,
|
||||||
|
|||||||
@ -182,7 +182,7 @@ void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) {
|
|||||||
RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.bitrate_bps));
|
RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.bitrate_bps));
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -23,8 +23,6 @@ struct CodecInst;
|
|||||||
|
|
||||||
class AudioEncoderOpus final : public AudioEncoder {
|
class AudioEncoderOpus final : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
enum ApplicationMode {
|
enum ApplicationMode {
|
||||||
kVoip = 0,
|
kVoip = 0,
|
||||||
kAudio = 1,
|
kAudio = 1,
|
||||||
@ -82,9 +80,9 @@ class AudioEncoderOpus final : public AudioEncoder {
|
|||||||
bool dtx_enabled() const { return config_.dtx_enabled; }
|
bool dtx_enabled() const { return config_.dtx_enabled; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t Num10msFramesPerPacket() const;
|
size_t Num10msFramesPerPacket() const;
|
||||||
|
|||||||
@ -19,8 +19,6 @@ struct CodecInst;
|
|||||||
|
|
||||||
class AudioEncoderPcm16B final : public AudioEncoderPcm {
|
class AudioEncoderPcm16B final : public AudioEncoderPcm {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
struct Config : public AudioEncoderPcm::Config {
|
struct Config : public AudioEncoderPcm::Config {
|
||||||
public:
|
public:
|
||||||
Config() : AudioEncoderPcm::Config(107), sample_rate_hz(8000) {}
|
Config() : AudioEncoderPcm::Config(107), sample_rate_hz(8000) {}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ int AudioEncoderCopyRed::GetTargetBitrate() const {
|
|||||||
return speech_encoder_->GetTargetBitrate();
|
return speech_encoder_->GetTargetBitrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal(
|
AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
||||||
uint32_t rtp_timestamp,
|
uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) {
|
rtc::Buffer* encoded) {
|
||||||
|
|||||||
@ -24,8 +24,6 @@ namespace webrtc {
|
|||||||
// into one packet.
|
// into one packet.
|
||||||
class AudioEncoderCopyRed final : public AudioEncoder {
|
class AudioEncoderCopyRed final : public AudioEncoder {
|
||||||
public:
|
public:
|
||||||
using AudioEncoder::EncodeInternal;
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
public:
|
public:
|
||||||
int payload_type;
|
int payload_type;
|
||||||
@ -53,9 +51,9 @@ class AudioEncoderCopyRed final : public AudioEncoder {
|
|||||||
void SetTargetBitrate(int target_bps) override;
|
void SetTargetBitrate(int target_bps) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
|
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||||
rtc::ArrayView<const int16_t> audio,
|
rtc::ArrayView<const int16_t> audio,
|
||||||
rtc::Buffer* encoded) override;
|
rtc::Buffer* encoded) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioEncoder* speech_encoder_;
|
AudioEncoder* speech_encoder_;
|
||||||
|
|||||||
@ -115,12 +115,12 @@ TEST_F(AudioEncoderCopyRedTest, CheckProjectedPacketLossRatePropagation) {
|
|||||||
// encoder.
|
// encoder.
|
||||||
TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) {
|
TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) {
|
||||||
// Interleaving the EXPECT_CALL sequence with expectations on the MockFunction
|
// Interleaving the EXPECT_CALL sequence with expectations on the MockFunction
|
||||||
// check ensures that exactly one call to EncodeInternal happens in each
|
// check ensures that exactly one call to EncodeImpl happens in each
|
||||||
// Encode call.
|
// Encode call.
|
||||||
InSequence s;
|
InSequence s;
|
||||||
MockFunction<void(int check_point_id)> check;
|
MockFunction<void(int check_point_id)> check;
|
||||||
for (int i = 1; i <= 6; ++i) {
|
for (int i = 1; i <= 6; ++i) {
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillRepeatedly(Return(AudioEncoder::EncodedInfo()));
|
.WillRepeatedly(Return(AudioEncoder::EncodedInfo()));
|
||||||
EXPECT_CALL(check, Call(i));
|
EXPECT_CALL(check, Call(i));
|
||||||
Encode();
|
Encode();
|
||||||
@ -134,7 +134,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckNoOutput) {
|
|||||||
static const size_t kEncodedSize = 17;
|
static const size_t kEncodedSize = 17;
|
||||||
{
|
{
|
||||||
InSequence s;
|
InSequence s;
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize)))
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize)))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(0)))
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(0)))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize)));
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize)));
|
||||||
@ -165,7 +165,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) {
|
|||||||
static const int kNumPackets = 10;
|
static const int kNumPackets = 10;
|
||||||
InSequence s;
|
InSequence s;
|
||||||
for (int encode_size = 1; encode_size <= kNumPackets; ++encode_size) {
|
for (int encode_size = 1; encode_size <= kNumPackets; ++encode_size) {
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(encode_size)));
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(encode_size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckTimestamps) {
|
|||||||
info.encoded_bytes = 17;
|
info.encoded_bytes = 17;
|
||||||
info.encoded_timestamp = timestamp_;
|
info.encoded_timestamp = timestamp_;
|
||||||
|
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
||||||
|
|
||||||
// First call is a special case, since it does not include a secondary
|
// First call is a special case, since it does not include a secondary
|
||||||
@ -202,7 +202,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckTimestamps) {
|
|||||||
uint32_t secondary_timestamp = primary_timestamp;
|
uint32_t secondary_timestamp = primary_timestamp;
|
||||||
primary_timestamp = timestamp_;
|
primary_timestamp = timestamp_;
|
||||||
info.encoded_timestamp = timestamp_;
|
info.encoded_timestamp = timestamp_;
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
||||||
|
|
||||||
Encode();
|
Encode();
|
||||||
@ -221,7 +221,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloads) {
|
|||||||
for (uint8_t i = 0; i < kPayloadLenBytes; ++i) {
|
for (uint8_t i = 0; i < kPayloadLenBytes; ++i) {
|
||||||
payload[i] = i;
|
payload[i] = i;
|
||||||
}
|
}
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillRepeatedly(Invoke(MockAudioEncoder::CopyEncoding(payload)));
|
.WillRepeatedly(Invoke(MockAudioEncoder::CopyEncoding(payload)));
|
||||||
|
|
||||||
// First call is a special case, since it does not include a secondary
|
// First call is a special case, since it does not include a secondary
|
||||||
@ -257,7 +257,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadType) {
|
|||||||
AudioEncoder::EncodedInfo info;
|
AudioEncoder::EncodedInfo info;
|
||||||
info.encoded_bytes = 17;
|
info.encoded_bytes = 17;
|
||||||
info.payload_type = primary_payload_type;
|
info.payload_type = primary_payload_type;
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
||||||
|
|
||||||
// First call is a special case, since it does not include a secondary
|
// First call is a special case, since it does not include a secondary
|
||||||
@ -269,7 +269,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadType) {
|
|||||||
|
|
||||||
const int secondary_payload_type = red_payload_type_ + 2;
|
const int secondary_payload_type = red_payload_type_ + 2;
|
||||||
info.payload_type = secondary_payload_type;
|
info.payload_type = secondary_payload_type;
|
||||||
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
|
EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _))
|
||||||
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
.WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info)));
|
||||||
|
|
||||||
Encode();
|
Encode();
|
||||||
|
|||||||
Reference in New Issue
Block a user