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

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

Issue 1695263002: Move direct use of VideoCapturer::VideoAdapter to VideoSinkWants. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Something like this? Created 4 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 e369ee07c632480404080415271572d593c87f06..157abbc372051f334704d3f9121c1aa1856bbebe 100644
--- a/webrtc/media/base/videobroadcaster.cc
+++ b/webrtc/media/base/videobroadcaster.cc
@@ -33,8 +33,43 @@ void VideoBroadcaster::AddOrUpdateSink(
// Rotation must be applied by the source if one sink wants it.
current_wants_.rotation_applied = false;
+ current_wants_.resolution =
+ rtc::Optional<VideoSinkWants::ResolutionRequest>();
+ rtc::Optional<VideoSinkWants::ResolutionRequest> resolution;
+ bool sink_agrees_on_resolution = true;
pthatcher1 2016/02/19 06:08:40 I think you mean sinks_agree_on_resolution
for (auto& sink_pair : sinks_) {
current_wants_.rotation_applied |= sink_pair.wants.rotation_applied;
+
+ if (sink_agrees_on_resolution && sink_pair.wants.resolution) {
+ if (sink_pair.wants.resolution->request ==
+ VideoSinkWants::ResolutionRequest::kLargerThan &&
+ sink_pair.wants.resolution->seen_number_of_pixels <
+ current_number_of_pixels_) {
pthatcher1 2016/02/19 06:08:40 This would be more clear reversed as "if (current
+ continue;
+ }
+
+ if (sink_pair.wants.resolution->request ==
+ VideoSinkWants::ResolutionRequest::kSmallerThan &&
+ sink_pair.wants.resolution->seen_number_of_pixels >
+ current_number_of_pixels_) {
pthatcher1 2016/02/19 06:08:40 Same here: "if (wants < current)" would be more cl
+ continue;
+ }
+
+ if (!resolution) {
+ resolution = sink_pair.wants.resolution;
+ continue;
+ }
+
+ if (*resolution != *sink_pair.wants.resolution) {
+ sink_agrees_on_resolution = false;
+ }
+ }
+ }
+
+ // If all sinks agree, the source should try to fulfill the resolution
+ // request.
+ if (sink_agrees_on_resolution) {
+ current_wants_.resolution = resolution;
}
}
@@ -63,6 +98,7 @@ VideoSinkWants VideoBroadcaster::wants() const {
void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ current_number_of_pixels_ = frame.GetWidth() * frame.GetHeight();
pthatcher1 2016/02/19 06:08:40 I think it would be better to save this as last_fr
pthatcher1 2016/02/19 06:08:40 Since the pixel count may have changed, I think yo
for (auto& sink_pair : sinks_) {
sink_pair.sink->OnFrame(frame);
}

Powered by Google App Engine
This is Rietveld 408576698