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

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: rebased 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..0ace19434e6d7af31d655fd1b02027305ee1df96 100644
--- a/webrtc/media/base/videobroadcaster.cc
+++ b/webrtc/media/base/videobroadcaster.cc
@@ -10,6 +10,8 @@
#include "webrtc/media/base/videobroadcaster.h"
+#include <limits>
+
#include "webrtc/base/checks.h"
namespace rtc {
@@ -30,12 +32,7 @@ void VideoBroadcaster::AddOrUpdateSink(
} else {
sink_pair->wants = wants;
}
-
- // Rotation must be applied by the source if one sink wants it.
- current_wants_.rotation_applied = false;
- for (auto& sink_pair : sinks_) {
- current_wants_.rotation_applied |= sink_pair.wants.rotation_applied;
- }
+ UpdateWants();
}
void VideoBroadcaster::RemoveSink(
@@ -49,6 +46,7 @@ void VideoBroadcaster::RemoveSink(
return sink_pair.sink == sink;
}),
sinks_.end());
+ UpdateWants();
}
bool VideoBroadcaster::frame_wanted() const {
@@ -79,4 +77,35 @@ VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair(
return nullptr;
}
+void VideoBroadcaster::UpdateWants() {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ // Rotation must be applied by the source if one sink wants it.
+ current_wants_.rotation_applied = false;
+ int max_pixels = std::numeric_limits<int>::max();
+ int more_than_pixels = std::numeric_limits<int>::max();
+ for (auto& sink_pair : sinks_) {
+ current_wants_.rotation_applied |= sink_pair.wants.rotation_applied;
+ if (sink_pair.wants.max_pixel_count &&
+ max_pixels > *sink_pair.wants.max_pixel_count) {
+ max_pixels = *sink_pair.wants.max_pixel_count;
+ }
+
+ if (sink_pair.wants.max_pixel_count_step_up &&
+ more_than_pixels > *sink_pair.wants.max_pixel_count_step_up) {
+ more_than_pixels = *sink_pair.wants.max_pixel_count_step_up;
+ }
+ }
+
+ current_wants_.max_pixel_count_step_up =
+ (more_than_pixels < std::numeric_limits<int>::max() &&
+ max_pixels > more_than_pixels)
+ ? rtc::Optional<int>(more_than_pixels)
+ : rtc::Optional<int>();
+
+ current_wants_.max_pixel_count =
+ (max_pixels < std::numeric_limits<int>::max())
+ ? rtc::Optional<int>(max_pixels)
+ : rtc::Optional<int>();
+}
+
pthatcher1 2016/02/25 07:40:30 I think this would be more readable: VideoSinkWan
nisse-webrtc 2016/02/25 09:31:07 I think there's one more thing done in Per's versi
perkj_webrtc 2016/02/25 13:57:07 Added that condition afterwards and went with ptha
} // namespace rtc

Powered by Google App Engine
This is Rietveld 408576698