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

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: 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 GetConstraintValue(constraints, MediaStreamVideoSource::kMaxWidth,
222 MediaStreamVideoSource::kMaxWidth,
223 desired_width);
224 mandatory |= GetConstraintValue(constraints, true,
225 MediaStreamVideoSource::kMaxHeight,
226 desired_height);
227 if (mandatory)
228 return;
229
230 GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxWidth,
231 desired_width); 211 desired_width);
232 GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxHeight, 212 GetConstraintValue(constraints, MediaStreamVideoSource::kMaxHeight,
233 desired_height); 213 desired_height);
234 } 214 }
235 215
236 const media::VideoCaptureFormat& GetBestFormatBasedOnArea( 216 const media::VideoCaptureFormat& GetBestFormatBasedOnArea(
237 const media::VideoCaptureFormats& formats, 217 const media::VideoCaptureFormats& formats,
238 int area) { 218 int area) {
239 media::VideoCaptureFormats::const_iterator it = formats.begin(); 219 media::VideoCaptureFormats::const_iterator it = formats.begin();
240 media::VideoCaptureFormats::const_iterator best_it = formats.begin(); 220 media::VideoCaptureFormats::const_iterator best_it = formats.begin();
241 int best_diff = std::numeric_limits<int>::max(); 221 int best_diff = std::numeric_limits<int>::max();
242 for (; it != formats.end(); ++it) { 222 for (; it != formats.end(); ++it) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 tracks_.push_back(track); 304 tracks_.push_back(track);
325 305
326 requested_constraints_.push_back( 306 requested_constraints_.push_back(
327 RequestedConstraints(constraints, callback)); 307 RequestedConstraints(constraints, callback));
328 308
329 switch (state_) { 309 switch (state_) {
330 case NEW: { 310 case NEW: {
331 // Tab capture and Screen capture needs the maximum requested height 311 // Tab capture and Screen capture needs the maximum requested height
332 // and width to decide on the resolution. 312 // and width to decide on the resolution.
333 int max_requested_width = 0; 313 int max_requested_width = 0;
334 GetConstraintValue(constraints, true, kMaxWidth, &max_requested_width); 314 GetManatoryConstraintValue(constraints, kMaxWidth, &max_requested_width);
tommi (sloooow) - chröme 2014/04/08 10:49:30 typo (here and throughout)
no longer working on chromium 2014/04/11 08:56:30 Done.
335 315
336 int max_requested_height = 0; 316 int max_requested_height = 0;
337 GetConstraintValue(constraints, true, kMaxHeight, &max_requested_height); 317 GetManatoryConstraintValue(constraints, kMaxHeight,
318 &max_requested_height);
338 319
339 state_ = RETRIEVING_CAPABILITIES; 320 state_ = RETRIEVING_CAPABILITIES;
340 GetCurrentSupportedFormats(max_requested_width, 321 GetCurrentSupportedFormats(max_requested_width,
341 max_requested_height); 322 max_requested_height);
342 323
343 break; 324 break;
344 } 325 }
345 case STARTING: 326 case STARTING:
346 case RETRIEVING_CAPABILITIES: { 327 case RETRIEVING_CAPABILITIES: {
347 // The |callback| will be triggered once the source has started or 328 // The |callback| will be triggered once the source has started or
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( 511 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints(
531 const blink::WebMediaConstraints& constraints, 512 const blink::WebMediaConstraints& constraints,
532 const ConstraintsCallback& callback) 513 const ConstraintsCallback& callback)
533 : constraints(constraints), callback(callback) { 514 : constraints(constraints), callback(callback) {
534 } 515 }
535 516
536 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 517 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
537 } 518 }
538 519
539 } // namespace content 520 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698