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

Side by Side Diff: content/renderer/media/media_stream_constraints_util_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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_constraints_util_video_source.h" 5 #include "content/renderer/media/media_stream_constraints_util_video_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "content/renderer/media/media_stream_video_source.h" 13 #include "content/renderer/media/media_stream_video_source.h"
14 #include "content/renderer/media/media_stream_video_track.h"
14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 15 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
15 #include "third_party/WebKit/public/platform/WebString.h" 16 #include "third_party/WebKit/public/platform/WebString.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 namespace { 20 namespace {
20 21
21 // Number of default settings to be used as final tie-breaking criteria for 22 // Number of default settings to be used as final tie-breaking criteria for
22 // settings that are equally good at satisfying constraints: 23 // settings that are equally good at satisfying constraints:
23 // device ID, power-line frequency, resolution and frame rate. 24 // device ID, power-line frequency, resolution and frame rate.
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 failed_constraint_name) + 301 failed_constraint_name) +
301 ResolutionConstraintSourceDistance(format.frame_size.width(), 302 ResolutionConstraintSourceDistance(format.frame_size.width(),
302 constraint_set.width, 303 constraint_set.width,
303 failed_constraint_name) + 304 failed_constraint_name) +
304 AspectRatioConstraintSourceDistance( 305 AspectRatioConstraintSourceDistance(
305 format.frame_size.height(), format.frame_size.width(), 306 format.frame_size.height(), format.frame_size.width(),
306 constraint_set.height, constraint_set.width, 307 constraint_set.height, constraint_set.width,
307 constraint_set.aspectRatio, failed_constraint_name) + 308 constraint_set.aspectRatio, failed_constraint_name) +
308 FrameRateConstraintSourceDistance(format.frame_rate, 309 FrameRateConstraintSourceDistance(format.frame_rate,
309 constraint_set.frameRate, 310 constraint_set.frameRate,
310 failed_constraint_name); 311 failed_constraint_name) +
312 StringConstraintSourceDistance(GetVideoKindForFormat(format),
313 constraint_set.videoKind,
314 failed_constraint_name);
311 } 315 }
312 316
313 // Returns a custom distance between a set of candidate settings and a 317 // Returns a custom distance between a set of candidate settings and a
314 // constraint set. It is simply the sum of the distances for each individual 318 // constraint set. It is simply the sum of the distances for each individual
315 // setting in |candidate|. 319 // setting in |candidate|.
316 // If |candidate| cannot satisfy constraint, the distance is HUGE_VAL. 320 // If |candidate| cannot satisfy constraint, the distance is HUGE_VAL.
317 // Otherwise the distance is a finite value. Candidates with lower distance 321 // Otherwise the distance is a finite value. Candidates with lower distance
318 // satisfy |constraint_set| in a "better" way. 322 // satisfy |constraint_set| in a "better" way.
319 double CandidateSourceDistance( 323 double CandidateSourceDistance(
320 const VideoCaptureSourceSettings& candidate, 324 const VideoCaptureSourceSettings& candidate,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 double fitness = 0.0; 474 double fitness = 0.0;
471 fitness += AspectRatioConstraintFitnessDistance( 475 fitness += AspectRatioConstraintFitnessDistance(
472 candidate.GetHeight(), candidate.GetWidth(), constraint_set.height, 476 candidate.GetHeight(), candidate.GetWidth(), constraint_set.height,
473 constraint_set.width, constraint_set.aspectRatio); 477 constraint_set.width, constraint_set.aspectRatio);
474 fitness += StringConstraintFitnessDistance(candidate.GetDeviceId(), 478 fitness += StringConstraintFitnessDistance(candidate.GetDeviceId(),
475 constraint_set.deviceId); 479 constraint_set.deviceId);
476 fitness += StringConstraintFitnessDistance(candidate.GetFacingMode(), 480 fitness += StringConstraintFitnessDistance(candidate.GetFacingMode(),
477 constraint_set.facingMode); 481 constraint_set.facingMode);
478 fitness += FrameRateConstraintFitnessDistance(candidate.GetFrameRate(), 482 fitness += FrameRateConstraintFitnessDistance(candidate.GetFrameRate(),
479 constraint_set.frameRate); 483 constraint_set.frameRate);
484 fitness += StringConstraintFitnessDistance(candidate.GetVideoKind(),
485 constraint_set.videoKind);
480 fitness += PowerLineFrequencyConstraintFitnessDistance( 486 fitness += PowerLineFrequencyConstraintFitnessDistance(
481 candidate.GetPowerLineFrequency(), constraint_set.googPowerLineFrequency); 487 candidate.GetPowerLineFrequency(), constraint_set.googPowerLineFrequency);
482 fitness += ResolutionConstraintFitnessDistance(candidate.GetHeight(), 488 fitness += ResolutionConstraintFitnessDistance(candidate.GetHeight(),
483 constraint_set.height); 489 constraint_set.height);
484 fitness += ResolutionConstraintFitnessDistance(candidate.GetWidth(), 490 fitness += ResolutionConstraintFitnessDistance(candidate.GetWidth(),
485 constraint_set.width); 491 constraint_set.width);
486 492
487 return fitness; 493 return fitness;
488 } 494 }
489 495
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 608 }
603 609
604 double VideoCaptureSourceSettings::GetFrameRate() const { 610 double VideoCaptureSourceSettings::GetFrameRate() const {
605 return format_.frame_rate; 611 return format_.frame_rate;
606 } 612 }
607 613
608 blink::WebString VideoCaptureSourceSettings::GetDeviceId() const { 614 blink::WebString VideoCaptureSourceSettings::GetDeviceId() const {
609 return blink::WebString::fromASCII(device_id_.data()); 615 return blink::WebString::fromASCII(device_id_.data());
610 } 616 }
611 617
618 blink::WebString VideoCaptureSourceSettings::GetVideoKind() const {
619 return GetVideoKindForFormat(format_);
620 }
621
612 const char kDefaultFailedConstraintName[] = ""; 622 const char kDefaultFailedConstraintName[] = "";
613 623
614 VideoCaptureSourceSelectionResult::VideoCaptureSourceSelectionResult() 624 VideoCaptureSourceSelectionResult::VideoCaptureSourceSelectionResult()
615 : failed_constraint_name(kDefaultFailedConstraintName) {} 625 : failed_constraint_name(kDefaultFailedConstraintName) {}
616 VideoCaptureSourceSelectionResult::VideoCaptureSourceSelectionResult( 626 VideoCaptureSourceSelectionResult::VideoCaptureSourceSelectionResult(
617 const VideoCaptureSourceSelectionResult& other) = default; 627 const VideoCaptureSourceSelectionResult& other) = default;
618 VideoCaptureSourceSelectionResult::VideoCaptureSourceSelectionResult( 628 VideoCaptureSourceSelectionResult::VideoCaptureSourceSelectionResult(
619 VideoCaptureSourceSelectionResult&& other) = default; 629 VideoCaptureSourceSelectionResult&& other) = default;
620 VideoCaptureSourceSelectionResult::~VideoCaptureSourceSelectionResult() = 630 VideoCaptureSourceSelectionResult::~VideoCaptureSourceSelectionResult() =
621 default; 631 default;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 733 }
724 } 734 }
725 735
726 if (!result.has_value()) 736 if (!result.has_value())
727 result.failed_constraint_name = failed_constraint_name; 737 result.failed_constraint_name = failed_constraint_name;
728 738
729 return result; 739 return result;
730 } 740 }
731 741
732 } // namespace content 742 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698