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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 } 74 }
75 75
76 void VideoBroadcaster::UpdateWants() { 76 void VideoBroadcaster::UpdateWants() {
77 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 77 RTC_DCHECK(thread_checker_.CalledOnValidThread());
78 78
79 VideoSinkWants wants; 79 VideoSinkWants wants;
80 wants.rotation_applied = false; 80 wants.rotation_applied = false;
81 for (auto& sink : sink_pairs()) { 81 for (auto& sink : sink_pairs()) {
82 // wants.rotation_applied == ANY(sink.wants.rotation_applied) 82 // wants.rotation_applied == ANY(sink.wants.rotation_applied)
83 if (sink.wants.rotation_applied) { 83 if (sink.wants.rotation_applied)
84 wants.rotation_applied = true; 84 wants.rotation_applied = true;
85 } 85
86 // wants.max_pixel_count == MIN(sink.wants.max_pixel_count) 86 if (sink.wants.pixel_count) {
87 if (sink.wants.max_pixel_count && 87 if (!wants.pixel_count) {
88 (!wants.max_pixel_count || 88 wants.pixel_count = sink.wants.pixel_count;
89 (*sink.wants.max_pixel_count < *wants.max_pixel_count))) { 89 } else {
90 wants.max_pixel_count = sink.wants.max_pixel_count; 90 // Merge the constraints if there are more than one wants. Lowest max
91 } 91 // will set the max cap and the highest min will set the min cap, as
92 // Select the minimum requested target_pixel_count, if any, of all sinks so 92 // these are pretty hard bounds. For now chose the min of the targets as
93 // that we don't over utilize the resources for any one. 93 // well, erring of the side of caution so that we don't overutilize some
94 // TODO(sprang): Consider using the median instead, since the limit can be 94 // resource.
95 // expressed by max_pixel_count. 95 // TODO(sprang): Consider using median of targets?
96 if (sink.wants.target_pixel_count && 96 wants.pixel_count->max = std::min<uint32_t>(
97 (!wants.target_pixel_count || 97 wants.pixel_count->max, sink.wants.pixel_count->max);
98 (*sink.wants.target_pixel_count < *wants.target_pixel_count))) { 98 wants.pixel_count->target = std::min<uint32_t>(
99 wants.target_pixel_count = sink.wants.target_pixel_count; 99 wants.pixel_count->target, sink.wants.pixel_count->target);
100 wants.pixel_count->min = std::max<uint32_t>(
101 wants.pixel_count->min, sink.wants.pixel_count->min);
102 }
100 } 103 }
101 } 104 }
102 105
103 if (wants.max_pixel_count && wants.target_pixel_count && 106 if (wants.pixel_count) {
104 *wants.target_pixel_count >= *wants.max_pixel_count) { 107 // Make sure there is no contradiction in the merged wants.
105 wants.target_pixel_count = wants.max_pixel_count; 108 wants.pixel_count->min =
109 std::min<uint32_t>(wants.pixel_count->min, wants.pixel_count->max);
110 wants.pixel_count->target =
111 std::min<uint32_t>(wants.pixel_count->target, wants.pixel_count->max);
112 wants.pixel_count->target =
113 std::max<uint32_t>(wants.pixel_count->target, wants.pixel_count->min);
106 } 114 }
107 current_wants_ = wants; 115 current_wants_ = wants;
108 } 116 }
109 117
110 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& 118 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>&
111 VideoBroadcaster::GetBlackFrameBuffer(int width, int height) { 119 VideoBroadcaster::GetBlackFrameBuffer(int width, int height) {
112 if (!black_frame_buffer_ || black_frame_buffer_->width() != width || 120 if (!black_frame_buffer_ || black_frame_buffer_->width() != width ||
113 black_frame_buffer_->height() != height) { 121 black_frame_buffer_->height() != height) {
114 rtc::scoped_refptr<webrtc::I420Buffer> buffer = 122 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
115 webrtc::I420Buffer::Create(width, height); 123 webrtc::I420Buffer::Create(width, height);
116 webrtc::I420Buffer::SetBlack(buffer.get()); 124 webrtc::I420Buffer::SetBlack(buffer.get());
117 black_frame_buffer_ = buffer; 125 black_frame_buffer_ = buffer;
118 } 126 }
119 127
120 return black_frame_buffer_; 128 return black_frame_buffer_;
121 } 129 }
122 130
123 } // namespace rtc 131 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698