diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 467647be5e..cdbab66995 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_format.h" #include "api/call/audio_sink.h" #include "api/rtp_parameters.h" +#include "api/sequence_checker.h" #include "audio/audio_send_stream.h" #include "audio/audio_state.h" #include "audio/channel_receive.h" @@ -118,7 +119,8 @@ AudioReceiveStream::AudioReceiveStream( const rtc::scoped_refptr& audio_state, webrtc::RtcEventLog* event_log, std::unique_ptr channel_receive) - : audio_state_(audio_state), + : config_(config), + audio_state_(audio_state), source_tracker_(clock), channel_receive_(std::move(channel_receive)) { RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.rtp.remote_ssrc; @@ -140,7 +142,15 @@ AudioReceiveStream::AudioReceiveStream( // Register with transport. rtp_stream_receiver_ = receiver_controller->CreateReceiver( config.rtp.remote_ssrc, channel_receive_.get()); - ConfigureStream(this, config, true); + + // Complete configuration. + // TODO(solenberg): Config NACK history window (which is a packet count), + // using the actual packet size for the configured codec. + channel_receive_->SetNACKStatus(config.rtp.nack.rtp_history_ms != 0, + config.rtp.nack.rtp_history_ms / 20); + channel_receive_->SetReceiveCodecs(config.decoder_map); + channel_receive_->SetDepacketizerToDecoderFrameTransformer( + config.frame_transformer); } AudioReceiveStream::~AudioReceiveStream() { @@ -154,7 +164,34 @@ AudioReceiveStream::~AudioReceiveStream() { void AudioReceiveStream::Reconfigure( const webrtc::AudioReceiveStream::Config& config) { RTC_DCHECK(worker_thread_checker_.IsCurrent()); - ConfigureStream(this, config, false); + + // Configuration parameters which cannot be changed. + RTC_DCHECK(config_.rtp.remote_ssrc == config.rtp.remote_ssrc); + RTC_DCHECK(config_.rtcp_send_transport == config.rtcp_send_transport); + // Decoder factory cannot be changed because it is configured at + // voe::Channel construction time. + RTC_DCHECK(config_.decoder_factory == config.decoder_factory); + + // SSRC can't be changed mid-stream. + RTC_DCHECK_EQ(config_.rtp.local_ssrc, config.rtp.local_ssrc); + RTC_DCHECK_EQ(config_.rtp.remote_ssrc, config.rtp.remote_ssrc); + + // TODO(solenberg): Config NACK history window (which is a packet count), + // using the actual packet size for the configured codec. + if (config_.rtp.nack.rtp_history_ms != config.rtp.nack.rtp_history_ms) { + channel_receive_->SetNACKStatus(config.rtp.nack.rtp_history_ms != 0, + config.rtp.nack.rtp_history_ms / 20); + } + if (config_.decoder_map != config.decoder_map) { + channel_receive_->SetReceiveCodecs(config.decoder_map); + } + + if (config_.frame_transformer != config.frame_transformer) { + channel_receive_->SetDepacketizerToDecoderFrameTransformer( + config.frame_transformer); + } + + config_ = config; } void AudioReceiveStream::Start() { @@ -384,50 +421,5 @@ internal::AudioState* AudioReceiveStream::audio_state() const { RTC_DCHECK(audio_state); return audio_state; } - -void AudioReceiveStream::ConfigureStream(AudioReceiveStream* stream, - const Config& new_config, - bool first_time) { - RTC_LOG(LS_INFO) << "AudioReceiveStream::ConfigureStream: " - << new_config.ToString(); - RTC_DCHECK(stream); - const auto& channel_receive = stream->channel_receive_; - const auto& old_config = stream->config_; - - // Configuration parameters which cannot be changed. - RTC_DCHECK(first_time || - old_config.rtp.remote_ssrc == new_config.rtp.remote_ssrc); - RTC_DCHECK(first_time || - old_config.rtcp_send_transport == new_config.rtcp_send_transport); - // Decoder factory cannot be changed because it is configured at - // voe::Channel construction time. - RTC_DCHECK(first_time || - old_config.decoder_factory == new_config.decoder_factory); - - if (!first_time) { - // SSRC can't be changed mid-stream. - RTC_DCHECK_EQ(old_config.rtp.local_ssrc, new_config.rtp.local_ssrc); - RTC_DCHECK_EQ(old_config.rtp.remote_ssrc, new_config.rtp.remote_ssrc); - } - - // TODO(solenberg): Config NACK history window (which is a packet count), - // using the actual packet size for the configured codec. - if (first_time || old_config.rtp.nack.rtp_history_ms != - new_config.rtp.nack.rtp_history_ms) { - channel_receive->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0, - new_config.rtp.nack.rtp_history_ms / 20); - } - if (first_time || old_config.decoder_map != new_config.decoder_map) { - channel_receive->SetReceiveCodecs(new_config.decoder_map); - } - - if (first_time || - old_config.frame_transformer != new_config.frame_transformer) { - channel_receive->SetDepacketizerToDecoderFrameTransformer( - new_config.frame_transformer); - } - - stream->config_ = new_config; -} } // namespace internal } // namespace webrtc diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index a8438c252a..769578ba3b 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -102,10 +102,6 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream, const AudioSendStream* GetAssociatedSendStreamForTesting() const; private: - static void ConfigureStream(AudioReceiveStream* stream, - const Config& new_config, - bool first_time); - AudioState* audio_state() const; SequenceChecker worker_thread_checker_;