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

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: GetVideoKindForFormat moved to utility. thanks guidou@. 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
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "content/child/child_process.h" 15 #include "content/child/child_process.h"
16 #include "content/renderer/media/media_stream_constraints_util_video_source.h"
16 #include "content/renderer/media/media_stream_video_track.h" 17 #include "content/renderer/media/media_stream_video_track.h"
17 #include "content/renderer/media/video_track_adapter.h" 18 #include "content/renderer/media/video_track_adapter.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
22 23
23 const char* const kLegalVideoConstraints[] = {"width", 24 const char* const kLegalVideoConstraints[] = {"width",
24 "height", 25 "height",
25 "aspectRatio", 26 "aspectRatio",
26 "frameRate", 27 "frameRate",
27 "facingMode", 28 "facingMode",
28 "deviceId", 29 "deviceId",
29 "groupId", 30 "groupId",
30 "mediaStreamSource", 31 "mediaStreamSource",
31 "googNoiseReduction"}; 32 "googNoiseReduction",
33 "videoKind"};
32 34
33 // Returns true if |constraint| has mandatory constraints. 35 // Returns true if |constraint| has mandatory constraints.
34 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) { 36 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) {
35 return constraints.basic().hasMandatory(); 37 return constraints.basic().hasMandatory();
36 } 38 }
37 39
38 // Retrieve the desired max width and height from |constraints|. If not set, 40 // Retrieve the desired max width and height from |constraints|. If not set,
39 // the |desired_width| and |desired_height| are set to 41 // the |desired_width| and |desired_height| are set to
40 // std::numeric_limits<int>::max(); 42 // std::numeric_limits<int>::max();
41 // If either max or exact width or height is set as a mandatory constraint, 43 // 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) || 137 (constraints.width.hasMax() && constraints.width.max() <= 0) ||
136 (constraints.width.hasExact() && 138 (constraints.width.hasExact() &&
137 constraints.width.exact() > format->frame_size.width())) { 139 constraints.width.exact() > format->frame_size.width())) {
138 *failing_constraint_name = constraints.width.name(); 140 *failing_constraint_name = constraints.width.name();
139 } else if ((constraints.height.hasMin() && 141 } else if ((constraints.height.hasMin() &&
140 constraints.height.min() > format->frame_size.height()) || 142 constraints.height.min() > format->frame_size.height()) ||
141 (constraints.height.hasMax() && constraints.height.max() <= 0) || 143 (constraints.height.hasMax() && constraints.height.max() <= 0) ||
142 (constraints.height.hasExact() && 144 (constraints.height.hasExact() &&
143 constraints.height.exact() > format->frame_size.height())) { 145 constraints.height.exact() > format->frame_size.height())) {
144 *failing_constraint_name = constraints.height.name(); 146 *failing_constraint_name = constraints.height.name();
147 } else if (constraints.videoKind.hasExact() &&
148 !constraints.videoKind.matches(GetVideoKindForFormat(*format))) {
149 *failing_constraint_name = constraints.videoKind.name();
145 } else if (!constraints.frameRate.matches(format->frame_rate)) { 150 } else if (!constraints.frameRate.matches(format->frame_rate)) {
146 if (constraints.frameRate.hasMax()) { 151 if (constraints.frameRate.hasMax()) {
147 const double value = constraints.frameRate.max(); 152 const double value = constraints.frameRate.max();
148 // TODO(hta): Check if handling of max = 0.0 is relevant. 153 // 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) 154 // (old handling was to set rate to 1.0 if 0.0 was specified)
150 if (constraints.frameRate.matches(value)) { 155 if (constraints.frameRate.matches(value)) {
151 format->frame_rate = 156 format->frame_rate =
152 (format->frame_rate > value) ? value : format->frame_rate; 157 (format->frame_rate > value) ? value : format->frame_rate;
153 return true; 158 return true;
154 } 159 }
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 callback(callback) { 623 callback(callback) {
619 } 624 }
620 625
621 MediaStreamVideoSource::TrackDescriptor::TrackDescriptor( 626 MediaStreamVideoSource::TrackDescriptor::TrackDescriptor(
622 const TrackDescriptor& other) = default; 627 const TrackDescriptor& other) = default;
623 628
624 MediaStreamVideoSource::TrackDescriptor::~TrackDescriptor() { 629 MediaStreamVideoSource::TrackDescriptor::~TrackDescriptor() {
625 } 630 }
626 631
627 } // namespace content 632 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698