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

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: addressed Per's comments. Created 6 years, 8 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 |= GetConstraintValue(constraints,
224 mandatory |= GetConstraintValue(constraints, true,
225 MediaStreamVideoSource::kMaxHeight, 213 MediaStreamVideoSource::kMaxHeight,
226 desired_height); 214 desired_height);
215 // Skip the optional constraints if any of the mandatory constraint is
216 // specified.
227 if (mandatory) 217 if (mandatory)
228 return; 218 return;
229 219
230 GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxWidth, 220 GetOptionalConstraintValue(constraints, MediaStreamVideoSource::kMaxWidth,
231 desired_width); 221 desired_width);
perkj_chrome 2014/04/15 13:01:06 nit: indentation
no longer working on chromium 2014/04/23 14:59:06 Done.
232 GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxHeight, 222 GetOptionalConstraintValue(constraints, MediaStreamVideoSource::kMaxHeight,
233 desired_height); 223 desired_height);
234 } 224 }
235 225
236 const media::VideoCaptureFormat& GetBestFormatBasedOnArea( 226 const media::VideoCaptureFormat& GetBestFormatBasedOnArea(
237 const media::VideoCaptureFormats& formats, 227 const media::VideoCaptureFormats& formats,
238 int area) { 228 int area) {
239 media::VideoCaptureFormats::const_iterator it = formats.begin(); 229 media::VideoCaptureFormats::const_iterator it = formats.begin();
240 media::VideoCaptureFormats::const_iterator best_it = formats.begin(); 230 media::VideoCaptureFormats::const_iterator best_it = formats.begin();
241 int best_diff = std::numeric_limits<int>::max(); 231 int best_diff = std::numeric_limits<int>::max();
242 for (; it != formats.end(); ++it) { 232 for (; it != formats.end(); ++it) {
243 int diff = abs(area - it->frame_size.width() * it->frame_size.height()); 233 int diff = abs(area - it->frame_size.width() * it->frame_size.height());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 tracks_.push_back(track); 310 tracks_.push_back(track);
321 311
322 requested_constraints_.push_back( 312 requested_constraints_.push_back(
323 RequestedConstraints(constraints, callback)); 313 RequestedConstraints(constraints, callback));
324 314
325 switch (state_) { 315 switch (state_) {
326 case NEW: { 316 case NEW: {
327 // Tab capture and Screen capture needs the maximum requested height 317 // Tab capture and Screen capture needs the maximum requested height
328 // and width to decide on the resolution. 318 // and width to decide on the resolution.
329 int max_requested_width = 0; 319 int max_requested_width = 0;
330 GetConstraintValue(constraints, true, kMaxWidth, &max_requested_width); 320 GetMandatoryConstraintValue(constraints, kMaxWidth, &max_requested_width);
331 321
332 int max_requested_height = 0; 322 int max_requested_height = 0;
333 GetConstraintValue(constraints, true, kMaxHeight, &max_requested_height); 323 GetMandatoryConstraintValue(constraints, kMaxHeight,
324 &max_requested_height);
perkj_chrome 2014/04/15 13:01:06 fits on line above?
no longer working on chromium 2014/04/23 14:59:06 No.
334 325
335 state_ = RETRIEVING_CAPABILITIES; 326 state_ = RETRIEVING_CAPABILITIES;
336 GetCurrentSupportedFormats(max_requested_width, 327 GetCurrentSupportedFormats(max_requested_width,
337 max_requested_height); 328 max_requested_height);
338 329
339 break; 330 break;
340 } 331 }
341 case STARTING: 332 case STARTING:
342 case RETRIEVING_CAPABILITIES: { 333 case RETRIEVING_CAPABILITIES: {
343 // The |callback| will be triggered once the source has started or 334 // The |callback| will be triggered once the source has started or
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( 513 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints(
523 const blink::WebMediaConstraints& constraints, 514 const blink::WebMediaConstraints& constraints,
524 const ConstraintsCallback& callback) 515 const ConstraintsCallback& callback)
525 : constraints(constraints), callback(callback) { 516 : constraints(constraints), callback(callback) {
526 } 517 }
527 518
528 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 519 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
529 } 520 }
530 521
531 } // namespace content 522 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698