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

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

Issue 2664673002: Media Capture Depth Stream Extensions API: videoKind settings and constraint. (Closed)
Patch Set: videoKind string constants removed from header. 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 // 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 10 matching lines...) Expand all
21 namespace { 21 namespace {
22 22
23 const char* const kLegalVideoConstraints[] = {"width", 23 const char* const kLegalVideoConstraints[] = {"width",
24 "height", 24 "height",
25 "aspectRatio", 25 "aspectRatio",
26 "frameRate", 26 "frameRate",
27 "facingMode", 27 "facingMode",
28 "deviceId", 28 "deviceId",
29 "groupId", 29 "groupId",
30 "mediaStreamSource", 30 "mediaStreamSource",
31 "googNoiseReduction"}; 31 "googNoiseReduction",
32 "videoKind"};
32 33
33 // Returns true if |constraint| has mandatory constraints. 34 // Returns true if |constraint| has mandatory constraints.
34 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) { 35 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) {
35 return constraints.basic().hasMandatory(); 36 return constraints.basic().hasMandatory();
36 } 37 }
37 38
38 // Retrieve the desired max width and height from |constraints|. If not set, 39 // Retrieve the desired max width and height from |constraints|. If not set,
39 // the |desired_width| and |desired_height| are set to 40 // the |desired_width| and |desired_height| are set to
40 // std::numeric_limits<int>::max(); 41 // std::numeric_limits<int>::max();
41 // If either max or exact width or height is set as a mandatory constraint, 42 // If either max or exact width or height is set as a mandatory constraint,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 (constraints.width.hasMax() && constraints.width.max() <= 0) || 136 (constraints.width.hasMax() && constraints.width.max() <= 0) ||
136 (constraints.width.hasExact() && 137 (constraints.width.hasExact() &&
137 constraints.width.exact() > format->frame_size.width())) { 138 constraints.width.exact() > format->frame_size.width())) {
138 *failing_constraint_name = constraints.width.name(); 139 *failing_constraint_name = constraints.width.name();
139 } else if ((constraints.height.hasMin() && 140 } else if ((constraints.height.hasMin() &&
140 constraints.height.min() > format->frame_size.height()) || 141 constraints.height.min() > format->frame_size.height()) ||
141 (constraints.height.hasMax() && constraints.height.max() <= 0) || 142 (constraints.height.hasMax() && constraints.height.max() <= 0) ||
142 (constraints.height.hasExact() && 143 (constraints.height.hasExact() &&
143 constraints.height.exact() > format->frame_size.height())) { 144 constraints.height.exact() > format->frame_size.height())) {
144 *failing_constraint_name = constraints.height.name(); 145 *failing_constraint_name = constraints.height.name();
146 } else if (constraints.videoKind.hasExact() &&
147 !constraints.videoKind.matches(GetVideoKindForFormat(*format))) {
148 *failing_constraint_name = constraints.videoKind.name();
145 } else if (!constraints.frameRate.matches(format->frame_rate)) { 149 } else if (!constraints.frameRate.matches(format->frame_rate)) {
146 if (constraints.frameRate.hasMax()) { 150 if (constraints.frameRate.hasMax()) {
147 const double value = constraints.frameRate.max(); 151 const double value = constraints.frameRate.max();
148 // TODO(hta): Check if handling of max = 0.0 is relevant. 152 // TODO(hta): Check if handling of max = 0.0 is relevant.
149 // (old handling was to set rate to 1.0 if 0.0 was specified) 153 // (old handling was to set rate to 1.0 if 0.0 was specified)
150 if (constraints.frameRate.matches(value)) { 154 if (constraints.frameRate.matches(value)) {
151 format->frame_rate = 155 format->frame_rate =
152 (format->frame_rate > value) ? value : format->frame_rate; 156 (format->frame_rate > value) ? value : format->frame_rate;
153 return true; 157 return true;
154 } 158 }
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 callback(callback) { 622 callback(callback) {
619 } 623 }
620 624
621 MediaStreamVideoSource::TrackDescriptor::TrackDescriptor( 625 MediaStreamVideoSource::TrackDescriptor::TrackDescriptor(
622 const TrackDescriptor& other) = default; 626 const TrackDescriptor& other) = default;
623 627
624 MediaStreamVideoSource::TrackDescriptor::~TrackDescriptor() { 628 MediaStreamVideoSource::TrackDescriptor::~TrackDescriptor() {
625 } 629 }
626 630
627 } // namespace content 631 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698