Add logging for video restrictions

This will help show what the restrictions are before
and after they transform into sink wants.

These will not be so spammy as adaptations do not happen
very often.

Bug: None
Change-Id: Ib72b313f68c6934d7833d8a3f14ce00df602832b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175800
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31341}
This commit is contained in:
Evan Shrubsole 2020-05-20 12:24:57 +02:00 committed by Commit Bot
parent f2c0f15282
commit 236e0ed83a
4 changed files with 40 additions and 1 deletions

View File

@ -11,9 +11,11 @@
#ifndef CALL_ADAPTATION_VIDEO_SOURCE_RESTRICTIONS_H_
#define CALL_ADAPTATION_VIDEO_SOURCE_RESTRICTIONS_H_
#include <string>
#include <utility>
#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<size_t>& max_pixels_per_frame() const;

View File

@ -14,10 +14,27 @@
#include <limits>
#include <utility>
#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<VideoFrame>* sink,
rtc::VideoSourceInterface<VideoFrame>* 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 {

View File

@ -11,6 +11,8 @@
#ifndef VIDEO_VIDEO_SOURCE_SINK_CONTROLLER_H_
#define VIDEO_VIDEO_SOURCE_SINK_CONTROLLER_H_
#include <string>
#include "absl/types/optional.h"
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"

View File

@ -1698,6 +1698,9 @@ void VideoStreamEncoder::OnVideoSourceRestrictionsUpdated(
const VideoAdaptationCounters& adaptation_counters,
rtc::scoped_refptr<Resource> reason) {
RTC_DCHECK_RUN_ON(&resource_adaptation_queue_);
std::string resource_name = reason ? reason->name() : "<null>";
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();
}