Fix crash when Opus maxptime < 20ms.
A follow up cl will be created to better handle nullopt frame length range in AudioSendStream. Note that maxptime is still not used for setting the frame length (only ptime is). Bug: chromium:1109337 Change-Id: Id21fd8c76a6c4a0c85719a955116f8d16001a3d4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284501 Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38702}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
b2556d7716
commit
918eb19303
@ -813,9 +813,10 @@ ANAStats AudioEncoderOpusImpl::GetANAStats() const {
|
||||
|
||||
absl::optional<std::pair<TimeDelta, TimeDelta> >
|
||||
AudioEncoderOpusImpl::GetFrameLengthRange() const {
|
||||
if (config_.supported_frame_lengths_ms.empty()) {
|
||||
return absl::nullopt;
|
||||
} else if (audio_network_adaptor_) {
|
||||
if (audio_network_adaptor_) {
|
||||
if (config_.supported_frame_lengths_ms.empty()) {
|
||||
return absl::nullopt;
|
||||
}
|
||||
return {{TimeDelta::Millis(config_.supported_frame_lengths_ms.front()),
|
||||
TimeDelta::Millis(config_.supported_frame_lengths_ms.back())}};
|
||||
} else {
|
||||
|
||||
@ -670,6 +670,17 @@ TEST(AudioEncoderOpusTest, TestConfigFromInvalidParams) {
|
||||
config.supported_frame_lengths_ms);
|
||||
}
|
||||
|
||||
TEST(AudioEncoderOpusTest, GetFrameLenghtRange) {
|
||||
AudioEncoderOpusConfig config =
|
||||
CreateConfigWithParameters({{"maxptime", "10"}, {"ptime", "10"}});
|
||||
std::unique_ptr<AudioEncoder> encoder =
|
||||
AudioEncoderOpus::MakeAudioEncoder(config, kDefaultOpusPayloadType);
|
||||
auto ptime = webrtc::TimeDelta::Millis(10);
|
||||
absl::optional<std::pair<webrtc::TimeDelta, webrtc::TimeDelta>> range = {
|
||||
{ptime, ptime}};
|
||||
EXPECT_EQ(encoder->GetFrameLengthRange(), range);
|
||||
}
|
||||
|
||||
// Test that bitrate will be overridden by the "maxaveragebitrate" parameter.
|
||||
// Also test that the "maxaveragebitrate" can't be set to values outside the
|
||||
// range of 6000 and 510000
|
||||
|
||||
Reference in New Issue
Block a user