Don't recreate the speech encoder if we don't have to
If the specification for the speech encoder hasn't changed, we should reuse it instead of recreating it. Otherwise, we lose its state. (This problem was originally discovered because AudioEncoderOpus instances would forget that they were supposed to be using DTX.) BUG=webrtc:6020, chromium:622647 Review-Url: https://codereview.webrtc.org/2089183002 Cr-Commit-Position: refs/heads/master@{#13273}
This commit is contained in:
@ -123,4 +123,9 @@ void AudioEncoderCopyRed::SetTargetBitrate(int bits_per_second) {
|
||||
speech_encoder_->SetTargetBitrate(bits_per_second);
|
||||
}
|
||||
|
||||
rtc::ArrayView<std::unique_ptr<AudioEncoder>>
|
||||
AudioEncoderCopyRed::ReclaimContainedEncoders() {
|
||||
return rtc::ArrayView<std::unique_ptr<AudioEncoder>>(&speech_encoder_, 1);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -51,6 +51,8 @@ class AudioEncoderCopyRed final : public AudioEncoder {
|
||||
void SetMaxPlaybackRate(int frequency_hz) override;
|
||||
void SetProjectedPacketLossRate(double fraction) override;
|
||||
void SetTargetBitrate(int target_bps) override;
|
||||
rtc::ArrayView<std::unique_ptr<AudioEncoder>> ReclaimContainedEncoders()
|
||||
override;
|
||||
|
||||
protected:
|
||||
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||
|
||||
Reference in New Issue
Block a user