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

@ -16,13 +16,6 @@
namespace webrtc {
bool AudioEncoderPcm16B::Config::IsOk() const {
if ((sample_rate_hz != 8000) && (sample_rate_hz != 16000) &&
(sample_rate_hz != 32000) && (sample_rate_hz != 48000))
return false;
return AudioEncoderPcm::Config::IsOk();
}
size_t AudioEncoderPcm16B::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
@ -45,9 +38,14 @@ AudioEncoderPcm16B::Config CreateConfig(const CodecInst& codec_inst) {
}
} // namespace
AudioEncoderMutablePcm16B::AudioEncoderMutablePcm16B(
const CodecInst& codec_inst)
: AudioEncoderMutableImpl<AudioEncoderPcm16B>(CreateConfig(codec_inst)) {
bool AudioEncoderPcm16B::Config::IsOk() const {
if ((sample_rate_hz != 8000) && (sample_rate_hz != 16000) &&
(sample_rate_hz != 32000) && (sample_rate_hz != 48000))
return false;
return AudioEncoderPcm::Config::IsOk();
}
AudioEncoderPcm16B::AudioEncoderPcm16B(const CodecInst& codec_inst)
: AudioEncoderPcm16B(CreateConfig(codec_inst)) {}
} // namespace webrtc

View File

@ -12,11 +12,12 @@
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_INCLUDE_AUDIO_ENCODER_PCM16B_H_
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/audio_coding/codecs/audio_encoder_mutable_impl.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h"
namespace webrtc {
struct CodecInst;
class AudioEncoderPcm16B final : public AudioEncoderPcm {
public:
struct Config : public AudioEncoderPcm::Config {
@ -29,6 +30,7 @@ class AudioEncoderPcm16B final : public AudioEncoderPcm {
explicit AudioEncoderPcm16B(const Config& config)
: AudioEncoderPcm(config, config.sample_rate_hz) {}
explicit AudioEncoderPcm16B(const CodecInst& codec_inst);
protected:
size_t EncodeCall(const int16_t* audio,
@ -38,13 +40,5 @@ class AudioEncoderPcm16B final : public AudioEncoderPcm {
int BytesPerSample() const override;
};
struct CodecInst;
class AudioEncoderMutablePcm16B
: public AudioEncoderMutableImpl<AudioEncoderPcm16B> {
public:
explicit AudioEncoderMutablePcm16B(const CodecInst& codec_inst);
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_INCLUDE_AUDIO_ENCODER_PCM16B_H_