Add PeerConnection option to enable RTX handling in the audio jitter buffer.

Bug: webrtc:10178
Change-Id: I70abce0c7b74124d2b1978d9a5eb8216b6233d1a
Reviewed-on: https://webrtc-review.googlesource.com/c/116784
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26203}
This commit is contained in:
Jakob Ivarsson 2019-01-10 15:58:36 +01:00 committed by Commit Bot
parent 43f3982d6f
commit 53eae87bf8
10 changed files with 41 additions and 4 deletions

View file

@ -52,6 +52,8 @@ void AudioOptions::SetAll(const AudioOptions& change) {
change.audio_jitter_buffer_fast_accelerate);
SetFrom(&audio_jitter_buffer_min_delay_ms,
change.audio_jitter_buffer_min_delay_ms);
SetFrom(&audio_jitter_buffer_enable_rtx_handling,
change.audio_jitter_buffer_enable_rtx_handling);
SetFrom(&typing_detection, change.typing_detection);
SetFrom(&experimental_agc, change.experimental_agc);
SetFrom(&extended_filter_aec, change.extended_filter_aec);
@ -81,6 +83,8 @@ bool AudioOptions::operator==(const AudioOptions& o) const {
o.audio_jitter_buffer_fast_accelerate &&
audio_jitter_buffer_min_delay_ms ==
o.audio_jitter_buffer_min_delay_ms &&
audio_jitter_buffer_enable_rtx_handling ==
o.audio_jitter_buffer_enable_rtx_handling &&
typing_detection == o.typing_detection &&
experimental_agc == o.experimental_agc &&
extended_filter_aec == o.extended_filter_aec &&
@ -114,6 +118,8 @@ std::string AudioOptions::ToString() const {
audio_jitter_buffer_fast_accelerate);
ToStringIfSet(&result, "audio_jitter_buffer_min_delay_ms",
audio_jitter_buffer_min_delay_ms);
ToStringIfSet(&result, "audio_jitter_buffer_enable_rtx_handling",
audio_jitter_buffer_enable_rtx_handling);
ToStringIfSet(&result, "typing", typing_detection);
ToStringIfSet(&result, "experimental_agc", experimental_agc);
ToStringIfSet(&result, "extended_filter_aec", extended_filter_aec);

View file

@ -56,6 +56,8 @@ struct AudioOptions {
absl::optional<bool> audio_jitter_buffer_fast_accelerate;
// Audio receiver jitter buffer (NetEq) minimum target delay in milliseconds.
absl::optional<int> audio_jitter_buffer_min_delay_ms;
// Audio receiver jitter buffer (NetEq) should handle retransmitted packets.
absl::optional<bool> audio_jitter_buffer_enable_rtx_handling;
// Audio processing to detect typing.
absl::optional<bool> typing_detection;
absl::optional<bool> experimental_agc;

View file

@ -454,6 +454,10 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
// The minimum delay in milliseconds for the audio jitter buffer.
int audio_jitter_buffer_min_delay_ms = 0;
// Whether the audio jitter buffer adapts the delay to retransmitted
// packets.
bool audio_jitter_buffer_enable_rtx_handling = false;
// Timeout in milliseconds before an ICE candidate pair is considered to be
// "not receiving", after which a lower priority candidate pair may be
// selected.

View file

@ -79,8 +79,8 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
config.media_transport, config.rtcp_send_transport, event_log,
config.rtp.remote_ssrc, config.jitter_buffer_max_packets,
config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms,
config.decoder_factory, config.codec_pair_id, config.frame_decryptor,
config.crypto_options);
config.jitter_buffer_enable_rtx_handling, config.decoder_factory,
config.codec_pair_id, config.frame_decryptor, config.crypto_options);
}
} // namespace

View file

@ -104,6 +104,7 @@ class ChannelReceive : public ChannelReceiveInterface,
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
int jitter_buffer_min_delay_ms,
bool jitter_buffer_enable_rtx_handling,
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
absl::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
@ -453,6 +454,7 @@ ChannelReceive::ChannelReceive(
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
int jitter_buffer_min_delay_ms,
bool jitter_buffer_enable_rtx_handling,
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
absl::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
@ -487,6 +489,8 @@ ChannelReceive::ChannelReceive(
acm_config.neteq_config.enable_fast_accelerate = jitter_buffer_fast_playout;
acm_config.neteq_config.min_delay_ms = jitter_buffer_min_delay_ms;
acm_config.neteq_config.enable_muted_state = true;
acm_config.neteq_config.enable_rtx_handling =
jitter_buffer_enable_rtx_handling;
audio_coding_.reset(AudioCodingModule::Create(acm_config));
_outputAudioLevel.Clear();
@ -988,6 +992,7 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
int jitter_buffer_min_delay_ms,
bool jitter_buffer_enable_rtx_handling,
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
absl::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
@ -996,8 +1001,8 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
module_process_thread, audio_device_module, media_transport,
rtcp_send_transport, rtc_event_log, remote_ssrc,
jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, decoder_factory, codec_pair_id,
frame_decryptor, crypto_options);
jitter_buffer_min_delay_ms, jitter_buffer_enable_rtx_handling,
decoder_factory, codec_pair_id, frame_decryptor, crypto_options);
}
} // namespace voe

View file

@ -139,6 +139,7 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
int jitter_buffer_min_delay_ms,
bool jitter_buffer_enable_rtx_handling,
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
absl::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,

View file

@ -115,6 +115,7 @@ class AudioReceiveStream {
size_t jitter_buffer_max_packets = 50;
bool jitter_buffer_fast_accelerate = false;
int jitter_buffer_min_delay_ms = 0;
bool jitter_buffer_enable_rtx_handling = false;
// Identifier for an A/V synchronization group. Empty string to disable.
// TODO(pbos): Synchronize streams in a sync group, not just one video

View file

@ -280,6 +280,7 @@ void WebRtcVoiceEngine::Init() {
options.audio_jitter_buffer_max_packets = 50;
options.audio_jitter_buffer_fast_accelerate = false;
options.audio_jitter_buffer_min_delay_ms = 0;
options.audio_jitter_buffer_enable_rtx_handling = false;
options.typing_detection = true;
options.experimental_agc = false;
options.extended_filter_aec = false;
@ -489,6 +490,12 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
audio_jitter_buffer_min_delay_ms_ =
*options.audio_jitter_buffer_min_delay_ms;
}
if (options.audio_jitter_buffer_enable_rtx_handling) {
RTC_LOG(LS_INFO) << "NetEq handle reordered packets? "
<< *options.audio_jitter_buffer_enable_rtx_handling;
audio_jitter_buffer_enable_rtx_handling_ =
*options.audio_jitter_buffer_enable_rtx_handling;
}
if (options.typing_detection) {
RTC_LOG(LS_INFO) << "Typing detection is enabled? "
@ -1096,6 +1103,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_accelerate,
int jitter_buffer_min_delay_ms,
bool jitter_buffer_enable_rtx_handling,
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options)
: call_(call), config_() {
@ -1110,6 +1118,8 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
config_.jitter_buffer_max_packets = jitter_buffer_max_packets;
config_.jitter_buffer_fast_accelerate = jitter_buffer_fast_accelerate;
config_.jitter_buffer_min_delay_ms = jitter_buffer_min_delay_ms;
config_.jitter_buffer_enable_rtx_handling =
jitter_buffer_enable_rtx_handling;
if (!stream_ids.empty()) {
config_.sync_group = stream_ids[0];
}
@ -1909,6 +1919,7 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
codec_pair_id_, engine()->audio_jitter_buffer_max_packets_,
engine()->audio_jitter_buffer_fast_accelerate_,
engine()->audio_jitter_buffer_min_delay_ms_,
engine()->audio_jitter_buffer_enable_rtx_handling_,
unsignaled_frame_decryptor_, crypto_options_)));
recv_streams_[ssrc]->SetPlayout(playout_);

View file

@ -133,6 +133,7 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface {
size_t audio_jitter_buffer_max_packets_ = 50;
bool audio_jitter_buffer_fast_accelerate_ = false;
int audio_jitter_buffer_min_delay_ms_ = 0;
bool audio_jitter_buffer_enable_rtx_handling_ = false;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceEngine);
};

View file

@ -706,6 +706,7 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
int audio_jitter_buffer_max_packets;
bool audio_jitter_buffer_fast_accelerate;
int audio_jitter_buffer_min_delay_ms;
bool audio_jitter_buffer_enable_rtx_handling;
int ice_connection_receiving_timeout;
int ice_backup_candidate_pair_ping_interval;
ContinualGatheringPolicy continual_gathering_policy;
@ -745,6 +746,8 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
o.audio_jitter_buffer_fast_accelerate &&
audio_jitter_buffer_min_delay_ms ==
o.audio_jitter_buffer_min_delay_ms &&
audio_jitter_buffer_enable_rtx_handling ==
o.audio_jitter_buffer_enable_rtx_handling &&
ice_connection_receiving_timeout ==
o.ice_connection_receiving_timeout &&
ice_backup_candidate_pair_ping_interval ==
@ -1071,6 +1074,9 @@ bool PeerConnection::Initialize(
audio_options_.audio_jitter_buffer_min_delay_ms =
configuration.audio_jitter_buffer_min_delay_ms;
audio_options_.audio_jitter_buffer_enable_rtx_handling =
configuration.audio_jitter_buffer_enable_rtx_handling;
// Whether the certificate generator/certificate is null or not determines
// what PeerConnectionDescriptionFactory will do, so make sure that we give it
// the right instructions by clearing the variables if needed.