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

Side by Side Diff: content/renderer/media/media_stream_constraints_util.cc

Issue 2870413004: Detect frames from rotated devices in VideoTrackAdapter on Android. (Closed)
Patch Set: address comment by tommi@ Created 3 years, 7 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_stream_constraints_util.h" 5 #include "content/renderer/media/media_stream_constraints_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (GetConstraintValueAsBoolean(constraints, picker, &value)) { 205 if (GetConstraintValueAsBoolean(constraints, picker, &value)) {
206 return rtc::Optional<bool>(value); 206 return rtc::Optional<bool>(value);
207 } 207 }
208 return rtc::Optional<bool>(); 208 return rtc::Optional<bool>();
209 } 209 }
210 210
211 VideoTrackAdapterSettings SelectVideoTrackAdapterSettings( 211 VideoTrackAdapterSettings SelectVideoTrackAdapterSettings(
212 const blink::WebMediaTrackConstraintSet& basic_constraint_set, 212 const blink::WebMediaTrackConstraintSet& basic_constraint_set,
213 const ResolutionSet& resolution_set, 213 const ResolutionSet& resolution_set,
214 const NumericRangeSet<double>& frame_rate_set, 214 const NumericRangeSet<double>& frame_rate_set,
215 const media::VideoCaptureFormat& source_format) { 215 const media::VideoCaptureFormat& source_format,
216 bool expect_source_native_size) {
216 ResolutionSet::Point resolution = resolution_set.SelectClosestPointToIdeal( 217 ResolutionSet::Point resolution = resolution_set.SelectClosestPointToIdeal(
217 basic_constraint_set, source_format.frame_size.height(), 218 basic_constraint_set, source_format.frame_size.height(),
218 source_format.frame_size.width()); 219 source_format.frame_size.width());
219 int track_max_height = static_cast<int>(std::round(resolution.height())); 220 int track_max_height = static_cast<int>(std::round(resolution.height()));
220 int track_max_width = static_cast<int>(std::round(resolution.width())); 221 int track_max_width = static_cast<int>(std::round(resolution.width()));
221 double track_min_aspect_ratio = 222 double track_min_aspect_ratio =
222 std::max(resolution_set.min_aspect_ratio(), 223 std::max(resolution_set.min_aspect_ratio(),
223 static_cast<double>(resolution_set.min_width()) / 224 static_cast<double>(resolution_set.min_width()) /
224 static_cast<double>(resolution_set.max_height())); 225 static_cast<double>(resolution_set.max_height()));
225 double track_max_aspect_ratio = 226 double track_max_aspect_ratio =
226 std::min(resolution_set.max_aspect_ratio(), 227 std::min(resolution_set.max_aspect_ratio(),
227 static_cast<double>(resolution_set.max_width()) / 228 static_cast<double>(resolution_set.max_width()) /
228 static_cast<double>(resolution_set.min_height())); 229 static_cast<double>(resolution_set.min_height()));
229 double track_max_frame_rate = frame_rate_set.Max(); 230 double track_max_frame_rate = frame_rate_set.Max();
230 if (basic_constraint_set.frame_rate.HasIdeal()) { 231 if (basic_constraint_set.frame_rate.HasIdeal()) {
231 track_max_frame_rate = std::min( 232 track_max_frame_rate = std::min(
232 track_max_frame_rate, std::max(basic_constraint_set.frame_rate.Ideal(), 233 track_max_frame_rate, std::max(basic_constraint_set.frame_rate.Ideal(),
233 frame_rate_set.Min())); 234 frame_rate_set.Min()));
234 } 235 }
235 // VideoTrackAdapter uses a frame rate of 0.0 to disable frame-rate 236 // VideoTrackAdapter uses a frame rate of 0.0 to disable frame-rate
236 // adjustment. 237 // adjustment.
237 if (track_max_frame_rate >= source_format.frame_rate) 238 if (track_max_frame_rate >= source_format.frame_rate)
238 track_max_frame_rate = 0.0; 239 track_max_frame_rate = 0.0;
239 240
241 base::Optional<gfx::Size> expected_native_size;
242 if (expect_source_native_size)
243 expected_native_size = source_format.frame_size;
244
240 return VideoTrackAdapterSettings( 245 return VideoTrackAdapterSettings(
241 track_max_width, track_max_height, track_min_aspect_ratio, 246 track_max_width, track_max_height, track_min_aspect_ratio,
242 track_max_aspect_ratio, track_max_frame_rate); 247 track_max_aspect_ratio, track_max_frame_rate, expected_native_size);
243 } 248 }
244 249
245 } // namespace content 250 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698