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

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

Issue 227743004: Added a kEchoCancellation constraint to turn off the audio processing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: GetEchoCancellationProperty handles both kEchoCancellation and kGoogEchoCancellation Created 6 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_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/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "content/renderer/media/media_stream_constraints_util.h"
13 #include "content/renderer/media/media_stream_dependency_factory.h" 14 #include "content/renderer/media/media_stream_dependency_factory.h"
14 #include "content/renderer/media/media_stream_video_track.h" 15 #include "content/renderer/media/media_stream_video_track.h"
15 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" 16 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b 20 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b
20 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio"; 21 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio";
21 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio"; 22 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio";
22 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth"; 23 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth";
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 FilterFormatsByConstraint(optional[i], false, &current_candidates); 197 FilterFormatsByConstraint(optional[i], false, &current_candidates);
197 if (!current_candidates.empty()) { 198 if (!current_candidates.empty()) {
198 candidates = current_candidates; 199 candidates = current_candidates;
199 } 200 }
200 } 201 }
201 202
202 // We have done as good as we can to filter the supported resolutions. 203 // We have done as good as we can to filter the supported resolutions.
203 return candidates; 204 return candidates;
204 } 205 }
205 206
206 bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
207 bool mandatory, const blink::WebString& name,
208 int* value) {
209 blink::WebString value_str;
210 bool ret = mandatory ?
211 constraints.getMandatoryConstraintValue(name, value_str) :
212 constraints.getOptionalConstraintValue(name, value_str);
213 if (ret)
214 base::StringToInt(value_str.utf8(), value);
215 return ret;
216 }
217
218 // Retrieve the desired max width and height from |constraints|. 207 // Retrieve the desired max width and height from |constraints|.
219 void GetDesiredMaxWidthAndHeight(const blink::WebMediaConstraints& constraints, 208 void GetDesiredMaxWidthAndHeight(const blink::WebMediaConstraints& constraints,
220 int* desired_width, int* desired_height) { 209 int* desired_width, int* desired_height) {
221 bool mandatory = GetConstraintValue(constraints, true, 210 bool mandatory = GetMandatoryConstraintValue(
222 MediaStreamVideoSource::kMaxWidth, 211 constraints, MediaStreamVideoSource::kMaxWidth, desired_width);
223 desired_width); 212 mandatory |= GetMandatoryConstraintValue(
224 mandatory |= GetConstraintValue(constraints, true, 213 constraints, MediaStreamVideoSource::kMaxHeight, desired_height);
225 MediaStreamVideoSource::kMaxHeight, 214 // Skip the optional constraints if any of the mandatory constraint is
226 desired_height); 215 // specified.
227 if (mandatory) 216 if (mandatory)
228 return; 217 return;
229 218
230 GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxWidth, 219 GetOptionalConstraintValue(constraints, MediaStreamVideoSource::kMaxWidth,
231 desired_width); 220 desired_width);
232 GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxHeight, 221 GetOptionalConstraintValue(constraints, MediaStreamVideoSource::kMaxHeight,
233 desired_height); 222 desired_height);
234 } 223 }
235 224
236 const media::VideoCaptureFormat& GetBestFormatBasedOnArea( 225 const media::VideoCaptureFormat& GetBestFormatBasedOnArea(
237 const media::VideoCaptureFormats& formats, 226 const media::VideoCaptureFormats& formats,
238 int area) { 227 int area) {
239 media::VideoCaptureFormats::const_iterator it = formats.begin(); 228 media::VideoCaptureFormats::const_iterator it = formats.begin();
240 media::VideoCaptureFormats::const_iterator best_it = formats.begin(); 229 media::VideoCaptureFormats::const_iterator best_it = formats.begin();
241 int best_diff = std::numeric_limits<int>::max(); 230 int best_diff = std::numeric_limits<int>::max();
242 for (; it != formats.end(); ++it) { 231 for (; it != formats.end(); ++it) {
243 int diff = abs(area - it->frame_size.width() * it->frame_size.height()); 232 int diff = abs(area - it->frame_size.width() * it->frame_size.height());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 tracks_.push_back(track); 306 tracks_.push_back(track);
318 307
319 requested_constraints_.push_back( 308 requested_constraints_.push_back(
320 RequestedConstraints(constraints, callback)); 309 RequestedConstraints(constraints, callback));
321 310
322 switch (state_) { 311 switch (state_) {
323 case NEW: { 312 case NEW: {
324 // Tab capture and Screen capture needs the maximum requested height 313 // Tab capture and Screen capture needs the maximum requested height
325 // and width to decide on the resolution. 314 // and width to decide on the resolution.
326 int max_requested_width = 0; 315 int max_requested_width = 0;
327 GetConstraintValue(constraints, true, kMaxWidth, &max_requested_width); 316 GetMandatoryConstraintValue(constraints, kMaxWidth, &max_requested_width);
328 317
329 int max_requested_height = 0; 318 int max_requested_height = 0;
330 GetConstraintValue(constraints, true, kMaxHeight, &max_requested_height); 319 GetMandatoryConstraintValue(constraints, kMaxHeight,
320 &max_requested_height);
331 321
332 state_ = RETRIEVING_CAPABILITIES; 322 state_ = RETRIEVING_CAPABILITIES;
333 GetCurrentSupportedFormats(max_requested_width, 323 GetCurrentSupportedFormats(max_requested_width,
334 max_requested_height); 324 max_requested_height);
335 325
336 break; 326 break;
337 } 327 }
338 case STARTING: 328 case STARTING:
339 case RETRIEVING_CAPABILITIES: { 329 case RETRIEVING_CAPABILITIES: {
340 // The |callback| will be triggered once the source has started or 330 // The |callback| will be triggered once the source has started or
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( 490 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints(
501 const blink::WebMediaConstraints& constraints, 491 const blink::WebMediaConstraints& constraints,
502 const ConstraintsCallback& callback) 492 const ConstraintsCallback& callback)
503 : constraints(constraints), callback(callback) { 493 : constraints(constraints), callback(callback) {
504 } 494 }
505 495
506 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 496 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
507 } 497 }
508 498
509 } // namespace content 499 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698