Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1380)

Unified Diff: webrtc/media/base/videobroadcaster.cc

Issue 2698203003: Update sink wants with ranges for both pixel count and frame rate.
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/media/base/videobroadcaster.cc
diff --git a/webrtc/media/base/videobroadcaster.cc b/webrtc/media/base/videobroadcaster.cc
index 5d0edeb6dfe4f9dc3129ba19231716f8caea03f5..17ee10baa2d9b50ac04b1ca8b26ccb620ae3f811 100644
--- a/webrtc/media/base/videobroadcaster.cc
+++ b/webrtc/media/base/videobroadcaster.cc
@@ -80,29 +80,37 @@ void VideoBroadcaster::UpdateWants() {
wants.rotation_applied = false;
for (auto& sink : sink_pairs()) {
// wants.rotation_applied == ANY(sink.wants.rotation_applied)
- if (sink.wants.rotation_applied) {
+ if (sink.wants.rotation_applied)
wants.rotation_applied = true;
- }
- // wants.max_pixel_count == MIN(sink.wants.max_pixel_count)
- if (sink.wants.max_pixel_count &&
- (!wants.max_pixel_count ||
- (*sink.wants.max_pixel_count < *wants.max_pixel_count))) {
- wants.max_pixel_count = sink.wants.max_pixel_count;
- }
- // Select the minimum requested target_pixel_count, if any, of all sinks so
- // that we don't over utilize the resources for any one.
- // TODO(sprang): Consider using the median instead, since the limit can be
- // expressed by max_pixel_count.
- if (sink.wants.target_pixel_count &&
- (!wants.target_pixel_count ||
- (*sink.wants.target_pixel_count < *wants.target_pixel_count))) {
- wants.target_pixel_count = sink.wants.target_pixel_count;
+
+ if (sink.wants.pixel_count) {
+ if (!wants.pixel_count) {
+ wants.pixel_count = sink.wants.pixel_count;
+ } else {
+ // Merge the constraints if there are more than one wants. Lowest max
+ // will set the max cap and the highest min will set the min cap, as
+ // these are pretty hard bounds. For now chose the min of the targets as
+ // well, erring of the side of caution so that we don't overutilize some
+ // resource.
+ // TODO(sprang): Consider using median of targets?
+ wants.pixel_count->max = std::min<uint32_t>(
+ wants.pixel_count->max, sink.wants.pixel_count->max);
+ wants.pixel_count->target = std::min<uint32_t>(
+ wants.pixel_count->target, sink.wants.pixel_count->target);
+ wants.pixel_count->min = std::max<uint32_t>(
+ wants.pixel_count->min, sink.wants.pixel_count->min);
+ }
}
}
- if (wants.max_pixel_count && wants.target_pixel_count &&
- *wants.target_pixel_count >= *wants.max_pixel_count) {
- wants.target_pixel_count = wants.max_pixel_count;
+ if (wants.pixel_count) {
+ // Make sure there is no contradiction in the merged wants.
+ wants.pixel_count->min =
+ std::min<uint32_t>(wants.pixel_count->min, wants.pixel_count->max);
+ wants.pixel_count->target =
+ std::min<uint32_t>(wants.pixel_count->target, wants.pixel_count->max);
+ wants.pixel_count->target =
+ std::max<uint32_t>(wants.pixel_count->target, wants.pixel_count->min);
}
current_wants_ = wants;
}

Powered by Google App Engine
This is Rietveld 408576698