diff --git a/call/adaptation/video_source_restrictions.h b/call/adaptation/video_source_restrictions.h index 506bae6133..9ee670dba5 100644 --- a/call/adaptation/video_source_restrictions.h +++ b/call/adaptation/video_source_restrictions.h @@ -11,9 +11,11 @@ #ifndef CALL_ADAPTATION_VIDEO_SOURCE_RESTRICTIONS_H_ #define CALL_ADAPTATION_VIDEO_SOURCE_RESTRICTIONS_H_ +#include #include #include "absl/types/optional.h" +#include "rtc_base/strings/string_builder.h" namespace webrtc { @@ -38,6 +40,19 @@ class VideoSourceRestrictions { return !(*this == rhs); } + std::string ToString() const { + rtc::StringBuilder ss; + ss << "{"; + if (max_frame_rate_) + ss << " max_fps=" << max_frame_rate_.value(); + if (max_pixels_per_frame_) + ss << " max_pixels_per_frame=" << max_pixels_per_frame_.value(); + if (target_pixels_per_frame_) + ss << " target_pixels_per_frame=" << target_pixels_per_frame_.value(); + ss << " }"; + return ss.Release(); + } + // The source must produce a resolution less than or equal to // max_pixels_per_frame(). const absl::optional& max_pixels_per_frame() const; diff --git a/video/video_source_sink_controller.cc b/video/video_source_sink_controller.cc index a649adc68c..ea1059c2e9 100644 --- a/video/video_source_sink_controller.cc +++ b/video/video_source_sink_controller.cc @@ -14,10 +14,27 @@ #include #include +#include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" namespace webrtc { +namespace { + +std::string WantsToString(const rtc::VideoSinkWants& wants) { + rtc::StringBuilder ss; + + ss << "max_fps=" << wants.max_framerate_fps + << " max_pixel_count=" << wants.max_pixel_count << " target_pixel_count=" + << (wants.target_pixel_count.has_value() + ? std::to_string(wants.target_pixel_count.value()) + : "null"); + + return ss.Release(); +} + +} // namespace + VideoSourceSinkController::VideoSourceSinkController( rtc::VideoSinkInterface* sink, rtc::VideoSourceInterface* source) @@ -46,7 +63,9 @@ void VideoSourceSinkController::PushSourceSinkSettings() { rtc::CritScope lock(&crit_); if (!source_) return; - source_->AddOrUpdateSink(sink_, CurrentSettingsToSinkWants()); + rtc::VideoSinkWants wants = CurrentSettingsToSinkWants(); + RTC_LOG(INFO) << "Pushing SourceSink restrictions: " << WantsToString(wants); + source_->AddOrUpdateSink(sink_, wants); } VideoSourceRestrictions VideoSourceSinkController::restrictions() const { diff --git a/video/video_source_sink_controller.h b/video/video_source_sink_controller.h index 68fef3f071..665493aa3d 100644 --- a/video/video_source_sink_controller.h +++ b/video/video_source_sink_controller.h @@ -11,6 +11,8 @@ #ifndef VIDEO_VIDEO_SOURCE_SINK_CONTROLLER_H_ #define VIDEO_VIDEO_SOURCE_SINK_CONTROLLER_H_ +#include + #include "absl/types/optional.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 1dd8d825d9..6d148cd62a 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -1698,6 +1698,9 @@ void VideoStreamEncoder::OnVideoSourceRestrictionsUpdated( const VideoAdaptationCounters& adaptation_counters, rtc::scoped_refptr reason) { RTC_DCHECK_RUN_ON(&resource_adaptation_queue_); + std::string resource_name = reason ? reason->name() : ""; + RTC_LOG(INFO) << "Updating sink restrictions from " << resource_name << " to " + << restrictions.ToString(); video_source_sink_controller_.SetRestrictions(std::move(restrictions)); video_source_sink_controller_.PushSourceSinkSettings(); }