Revert of Remove the deprecated EncodeInternal interface from AudioEncoder (patchset #4 id:60001 of https://codereview.webrtc.org/1864993002/ )

Reason for revert:
Broke import. Implementations of the old interface still exists somewhere.

Original issue's description:
> Remove the deprecated EncodeInternal interface from AudioEncoder
>
> Also hid MaxEncodedBytes by making it private. It will get removed as soon as subclasses have had time to remove their overrides.
>
> BUG=webrtc:5591
>
> Committed: https://crrev.com/5222d315dbea8f3563c100cc9f2451907f70b05f
> Cr-Commit-Position: refs/heads/master@{#12329}

TBR=kwiberg@webrtc.org,solenberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5591

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

Cr-Commit-Position: refs/heads/master@{#12330}
This commit is contained in:
ossu
2016-04-12 03:58:07 -07:00
committed by Commit bot
parent 5222d315db
commit 164bc4bbd3
23 changed files with 278 additions and 36 deletions

View File

@ -100,6 +100,16 @@ AudioEncoderOpus::~AudioEncoderOpus() {
RTC_CHECK_EQ(0, WebRtcOpus_EncoderFree(inst_));
}
size_t AudioEncoderOpus::MaxEncodedBytes() const {
// Calculate the number of bytes we expect the encoder to produce,
// then multiply by two to give a wide margin for error.
const size_t bytes_per_millisecond =
static_cast<size_t>(config_.bitrate_bps / (1000 * 8) + 1);
const size_t approx_encoded_bytes =
Num10msFramesPerPacket() * 10 * bytes_per_millisecond;
return 2 * approx_encoded_bytes;
}
int AudioEncoderOpus::SampleRateHz() const {
return kSampleRateHz;
}
@ -188,7 +198,7 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeImpl(
RTC_CHECK_EQ(input_buffer_.size(),
Num10msFramesPerPacket() * SamplesPer10msFrame());
const size_t max_encoded_bytes = ApproximateEncodedBytes();
const size_t max_encoded_bytes = MaxEncodedBytes();
EncodedInfo info;
info.encoded_bytes =
encoded->AppendData(
@ -221,16 +231,6 @@ size_t AudioEncoderOpus::SamplesPer10msFrame() const {
return rtc::CheckedDivExact(kSampleRateHz, 100) * config_.num_channels;
}
size_t AudioEncoderOpus::ApproximateEncodedBytes() const {
// Calculate the number of bytes we expect the encoder to produce,
// then multiply by two to give a wide margin for error.
const size_t bytes_per_millisecond =
static_cast<size_t>(config_.bitrate_bps / (1000 * 8) + 1);
const size_t approx_encoded_bytes =
Num10msFramesPerPacket() * 10 * bytes_per_millisecond;
return 2 * approx_encoded_bytes;
}
// If the given config is OK, recreate the Opus encoder instance with those
// settings, save the config, and return true. Otherwise, do nothing and return
// false.

View File

@ -54,6 +54,7 @@ class AudioEncoderOpus final : public AudioEncoder {
explicit AudioEncoderOpus(const CodecInst& codec_inst);
~AudioEncoderOpus() override;
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
size_t NumChannels() const override;
size_t Num10MsFramesInNextPacket() const override;
@ -78,7 +79,7 @@ class AudioEncoderOpus final : public AudioEncoder {
ApplicationMode application() const { return config_.application; }
bool dtx_enabled() const { return config_.dtx_enabled; }
protected:
protected:
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
rtc::ArrayView<const int16_t> audio,
rtc::Buffer* encoded) override;
@ -86,7 +87,6 @@ class AudioEncoderOpus final : public AudioEncoder {
private:
size_t Num10msFramesPerPacket() const;
size_t SamplesPer10msFrame() const;
size_t ApproximateEncodedBytes() const;
bool RecreateEncoderInstance(const Config& config);
Config config_;