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

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

Issue 442643002: Allow MediaStream constraints to specify higher than 30 FPS tab capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile whoops. Created 6 years, 4 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 | Annotate | Revision Log
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_video_source.h" 5 #include "content/renderer/media/media_stream_video_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 if (constraint_name == MediaStreamVideoSource::kMinWidth) { 167 if (constraint_name == MediaStreamVideoSource::kMinWidth) {
168 return (value <= format->frame_size.width()); 168 return (value <= format->frame_size.width());
169 } else if (constraint_name == MediaStreamVideoSource::kMaxWidth) { 169 } else if (constraint_name == MediaStreamVideoSource::kMaxWidth) {
170 return value > 0.0; 170 return value > 0.0;
171 } else if (constraint_name == MediaStreamVideoSource::kMinHeight) { 171 } else if (constraint_name == MediaStreamVideoSource::kMinHeight) {
172 return (value <= format->frame_size.height()); 172 return (value <= format->frame_size.height());
173 } else if (constraint_name == MediaStreamVideoSource::kMaxHeight) { 173 } else if (constraint_name == MediaStreamVideoSource::kMaxHeight) {
174 return value > 0.0; 174 return value > 0.0;
175 } else if (constraint_name == MediaStreamVideoSource::kMinFrameRate) { 175 } else if (constraint_name == MediaStreamVideoSource::kMinFrameRate) {
176 return (value <= format->frame_rate); 176 return (value > 0.0) && (value <= format->frame_rate);
177 } else if (constraint_name == MediaStreamVideoSource::kMaxFrameRate) { 177 } else if (constraint_name == MediaStreamVideoSource::kMaxFrameRate) {
178 if (value == 0.0) { 178 if (value <= 0.0) {
179 // The frame rate is set by constraint. 179 // The frame rate is set by constraint.
180 // Don't allow 0 as frame rate if it is a mandatory constraint. 180 // Don't allow 0 as frame rate if it is a mandatory constraint.
181 // Set the frame rate to 1 if it is not mandatory. 181 // Set the frame rate to 1 if it is not mandatory.
182 if (mandatory) { 182 if (mandatory) {
183 return false; 183 return false;
184 } else { 184 } else {
185 value = 1.0; 185 value = 1.0;
186 } 186 }
187 } 187 }
188 format->frame_rate = 188 format->frame_rate =
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Tab capture and Screen capture needs the maximum requested height 380 // Tab capture and Screen capture needs the maximum requested height
381 // and width to decide on the resolution. 381 // and width to decide on the resolution.
382 int max_requested_width = 0; 382 int max_requested_width = 0;
383 GetMandatoryConstraintValueAsInteger(constraints, kMaxWidth, 383 GetMandatoryConstraintValueAsInteger(constraints, kMaxWidth,
384 &max_requested_width); 384 &max_requested_width);
385 385
386 int max_requested_height = 0; 386 int max_requested_height = 0;
387 GetMandatoryConstraintValueAsInteger(constraints, kMaxHeight, 387 GetMandatoryConstraintValueAsInteger(constraints, kMaxHeight,
388 &max_requested_height); 388 &max_requested_height);
389 389
390 double max_requested_frame_rate;
391 if (!GetConstraintValueAsDouble(constraints, kMaxFrameRate,
392 &max_requested_frame_rate)) {
393 max_requested_frame_rate = kDefaultFrameRate;
394 }
395
390 state_ = RETRIEVING_CAPABILITIES; 396 state_ = RETRIEVING_CAPABILITIES;
391 GetCurrentSupportedFormats( 397 GetCurrentSupportedFormats(
392 max_requested_width, 398 max_requested_width,
393 max_requested_height, 399 max_requested_height,
400 max_requested_frame_rate,
394 base::Bind(&MediaStreamVideoSource::OnSupportedFormats, 401 base::Bind(&MediaStreamVideoSource::OnSupportedFormats,
395 weak_factory_.GetWeakPtr())); 402 weak_factory_.GetWeakPtr()));
396 403
397 break; 404 break;
398 } 405 }
399 case STARTING: 406 case STARTING:
400 case RETRIEVING_CAPABILITIES: { 407 case RETRIEVING_CAPABILITIES: {
401 // The |callback| will be triggered once the source has started or 408 // The |callback| will be triggered once the source has started or
402 // the capabilities have been retrieved. 409 // the capabilities have been retrieved.
403 break; 410 break;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 : track(track), 617 : track(track),
611 frame_callback(frame_callback), 618 frame_callback(frame_callback),
612 constraints(constraints), 619 constraints(constraints),
613 callback(callback) { 620 callback(callback) {
614 } 621 }
615 622
616 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 623 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
617 } 624 }
618 625
619 } // namespace content 626 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_video_source.h ('k') | content/renderer/media/mock_media_stream_video_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698