diff --git a/audio/BUILD.gn b/audio/BUILD.gn index b44bbe54ac..654e810dad 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -65,6 +65,7 @@ rtc_static_library("audio") { "../common_audio:common_audio_c", "../logging:rtc_event_audio", "../logging:rtc_event_log_api", + "../logging:rtc_stream_config", "../modules/audio_coding", "../modules/audio_coding:audio_format_conversion", "../modules/audio_coding:audio_network_adaptor_config", diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index f778745e31..f11dace832 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -28,6 +28,9 @@ #include "call/rtp_transport_controller_send_interface.h" #include "common_audio/vad/include/vad.h" #include "common_types.h" // NOLINT(build/include) +#include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h" +#include "logging/rtc_event_log/rtc_event_log.h" +#include "logging/rtc_event_log/rtc_stream_config.h" #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" #include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/checks.h" @@ -69,6 +72,39 @@ std::unique_ptr CreateChannelAndProxy( worker_queue, module_process_thread, media_transport, rtcp_rtt_stats, event_log, frame_encryptor, crypto_options, extmap_allow_mixed)); } + +void UpdateEventLogStreamConfig(RtcEventLog* event_log, + const AudioSendStream::Config& config, + const AudioSendStream::Config* old_config) { + using SendCodecSpec = AudioSendStream::Config::SendCodecSpec; + // Only update if any of the things we log have changed. + auto payload_types_equal = [](const absl::optional& a, + const absl::optional& b) { + if (a.has_value() && b.has_value()) { + return a->format.name == b->format.name && + a->payload_type == b->payload_type; + } + return !a.has_value() && !b.has_value(); + }; + + if (old_config && config.rtp.ssrc == old_config->rtp.ssrc && + config.rtp.extensions == old_config->rtp.extensions && + payload_types_equal(config.send_codec_spec, + old_config->send_codec_spec)) { + return; + } + + auto rtclog_config = absl::make_unique(); + rtclog_config->local_ssrc = config.rtp.ssrc; + rtclog_config->rtp_extensions = config.rtp.extensions; + if (config.send_codec_spec) { + rtclog_config->codecs.emplace_back(config.send_codec_spec->format.name, + config.send_codec_spec->payload_type, 0); + } + event_log->Log(absl::make_unique( + std::move(rtclog_config))); +} + } // namespace // Helper class to track the actively sending lifetime of this stream. @@ -221,6 +257,9 @@ void AudioSendStream::ConfigureStream( bool first_time) { RTC_LOG(LS_INFO) << "AudioSendStream::ConfigureStream: " << new_config.ToString(); + UpdateEventLogStreamConfig(stream->event_log_, new_config, + first_time ? nullptr : &stream->config_); + const auto& channel_proxy = stream->channel_proxy_; const auto& old_config = stream->config_; diff --git a/call/call.cc b/call/call.cc index 1ecaa613e9..1233ecdb7c 100644 --- a/call/call.cc +++ b/call/call.cc @@ -30,7 +30,6 @@ #include "call/rtp_stream_receiver_controller.h" #include "call/rtp_transport_controller_send.h" #include "logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h" -#include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h" #include "logging/rtc_event_log/events/rtc_event_rtcp_packet_incoming.h" #include "logging/rtc_event_log/events/rtc_event_rtp_packet_incoming.h" #include "logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h" @@ -147,18 +146,6 @@ std::unique_ptr CreateRtcLogStreamConfig( return rtclog_config; } -std::unique_ptr CreateRtcLogStreamConfig( - const AudioSendStream::Config& config) { - auto rtclog_config = absl::make_unique(); - rtclog_config->local_ssrc = config.rtp.ssrc; - rtclog_config->rtp_extensions = config.rtp.extensions; - if (config.send_codec_spec) { - rtclog_config->codecs.emplace_back(config.send_codec_spec->format.name, - config.send_codec_spec->payload_type, 0); - } - return rtclog_config; -} - } // namespace namespace internal { @@ -579,9 +566,8 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream( const webrtc::AudioSendStream::Config& config) { TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); RTC_DCHECK_CALLED_SEQUENTIALLY(&configuration_sequence_checker_); - event_log_->Log(absl::make_unique( - CreateRtcLogStreamConfig(config))); - + // Stream config is logged in AudioSendStream::ConfigureStream, as it may + // change during the stream's lifetime. absl::optional suspended_rtp_state; { const auto& iter = suspended_audio_send_ssrcs_.find(config.rtp.ssrc);