Fold AudioEncoderMutable into AudioEncoder

It makes more sense to combine the two interfaces, since there wasn't
a clear line separating them. The result is a combined interface with
just over a dozen methods, half of which need to be implemented by
every subclass, while the other half have sensible (and trivial)
default implementations and are implemented only by the few subclasses
that need non-default behavior.

Review URL: https://codereview.webrtc.org/1322973004

Cr-Commit-Position: refs/heads/master@{#9894}
This commit is contained in:
kwiberg
2015-09-08 05:57:53 -07:00
committed by Commit bot
parent cd3c475407
commit 12cfc9b4da
40 changed files with 851 additions and 984 deletions

View File

@ -22,23 +22,22 @@ AudioEncoderCopyRed::AudioEncoderCopyRed(const Config& config)
CHECK(speech_encoder_) << "Speech encoder not provided.";
}
AudioEncoderCopyRed::~AudioEncoderCopyRed() {
AudioEncoderCopyRed::~AudioEncoderCopyRed() = default;
size_t AudioEncoderCopyRed::MaxEncodedBytes() const {
return 2 * speech_encoder_->MaxEncodedBytes();
}
int AudioEncoderCopyRed::SampleRateHz() const {
return speech_encoder_->SampleRateHz();
}
int AudioEncoderCopyRed::RtpTimestampRateHz() const {
return speech_encoder_->RtpTimestampRateHz();
}
int AudioEncoderCopyRed::NumChannels() const {
return speech_encoder_->NumChannels();
}
size_t AudioEncoderCopyRed::MaxEncodedBytes() const {
return 2 * speech_encoder_->MaxEncodedBytes();
int AudioEncoderCopyRed::RtpTimestampRateHz() const {
return speech_encoder_->RtpTimestampRateHz();
}
size_t AudioEncoderCopyRed::Num10MsFramesInNextPacket() const {
@ -53,16 +52,6 @@ int AudioEncoderCopyRed::GetTargetBitrate() const {
return speech_encoder_->GetTargetBitrate();
}
void AudioEncoderCopyRed::SetTargetBitrate(int bits_per_second) {
speech_encoder_->SetTargetBitrate(bits_per_second);
}
void AudioEncoderCopyRed::SetProjectedPacketLossRate(double fraction) {
DCHECK_GE(fraction, 0.0);
DCHECK_LE(fraction, 1.0);
speech_encoder_->SetProjectedPacketLossRate(fraction);
}
AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal(
uint32_t rtp_timestamp,
const int16_t* audio,
@ -102,4 +91,42 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal(
return info;
}
void AudioEncoderCopyRed::Reset() {
speech_encoder_->Reset();
secondary_encoded_.Clear();
secondary_info_.encoded_bytes = 0;
}
bool AudioEncoderCopyRed::SetFec(bool enable) {
return speech_encoder_->SetFec(enable);
}
bool AudioEncoderCopyRed::SetDtx(bool enable) {
return speech_encoder_->SetDtx(enable);
}
bool AudioEncoderCopyRed::SetApplication(Application application) {
return speech_encoder_->SetApplication(application);
}
bool AudioEncoderCopyRed::SetMaxPlaybackRate(int frequency_hz) {
return speech_encoder_->SetMaxPlaybackRate(frequency_hz);
}
void AudioEncoderCopyRed::SetProjectedPacketLossRate(double fraction) {
speech_encoder_->SetProjectedPacketLossRate(fraction);
}
void AudioEncoderCopyRed::SetTargetBitrate(int bits_per_second) {
speech_encoder_->SetTargetBitrate(bits_per_second);
}
void AudioEncoderCopyRed::SetMaxBitrate(int max_bps) {
speech_encoder_->SetMaxBitrate(max_bps);
}
void AudioEncoderCopyRed::SetMaxPayloadSize(int max_payload_size_bytes) {
speech_encoder_->SetMaxPayloadSize(max_payload_size_bytes);
}
} // namespace webrtc

View File

@ -23,7 +23,7 @@ namespace webrtc {
// underlying AudioEncoder object that performs the actual encodings. The
// current class will gather the two latest encodings from the underlying codec
// into one packet.
class AudioEncoderCopyRed : public AudioEncoder {
class AudioEncoderCopyRed final : public AudioEncoder {
public:
struct Config {
public:
@ -36,19 +36,26 @@ class AudioEncoderCopyRed : public AudioEncoder {
~AudioEncoderCopyRed() override;
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t MaxEncodedBytes() const override;
int RtpTimestampRateHz() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
int GetTargetBitrate() const override;
void SetTargetBitrate(int bits_per_second) override;
void SetProjectedPacketLossRate(double fraction) override;
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
const int16_t* audio,
size_t max_encoded_bytes,
uint8_t* encoded) override;
void Reset() override;
bool SetFec(bool enable) override;
bool SetDtx(bool enable) override;
bool SetApplication(Application application) override;
bool SetMaxPlaybackRate(int frequency_hz) override;
void SetProjectedPacketLossRate(double fraction) override;
void SetTargetBitrate(int target_bps) override;
void SetMaxBitrate(int max_bps) override;
void SetMaxPayloadSize(int max_payload_size_bytes) override;
private:
AudioEncoder* speech_encoder_;